0

I have a tooltip that shows up, but I want the heading and text in it to be different styles.

HTML:

<div class="base">HEADING
<span class="base-hover">
<!-- Different style here -->
This is the text under the heading.
<span>
</div>

CSS:

.base {
width: 100px;
height: 50px;
font-size: 18px;
color: red;
text-align: center;
position: relative;
display: inline-block.
}

.base .base-hover {
visibility: hidden;
right: 30px;
bottom: 10px;
}

.base:hover .base-hover {
visibility: visible;
position: relative;
display: inline-block;
width: 100px;
height: 50px;
padding: 10px 60px;
white-space: pre-line;
text-align: center;
}

Understandably, this only has one style, font color red. I'd like the content to be black, but I can't add any colors without changing everything in the tooltip. If I try to separate the spans with another <span> or <p>, two tooltip boxes come up.

Thank you.

2 Answers 2

1

You are missing the = sign in class="base-hover"

.base {
  width: 100px;
  height: 50px;
  font-size: 18px;
  color: red;
  text-align: center;
  position: relative;
  display: inline-block.
}

.base .base-hover {
  visibility: hidden;
  right: 30px;
  bottom: 10px;
}

.base:hover .base-hover {
  visibility: visible;
  position: relative;
  display: inline-block;
  width: 100px;
  height: 50px;
  padding: 10px 60px;
  white-space: pre-line;
  text-align: center;
}
<div class="base">
  HEADING
  <span class="base-hover">
    This is the text under the heading.
  </span>
</div>

Sign up to request clarification or add additional context in comments.

Comments

1

yes you can give different color. give color style to base-hover element also

.base {
width: 100px;
height: 50px;
font-size: 18px;
color: red;
text-align: center;
position: relative;
display: inline-block.
}

.base .base-hover {
visibility: hidden;
right: 30px;
bottom: 10px;
}

.base:hover .base-hover {
visibility: visible;
position: relative;
display: inline-block;
width: 100px;
height: 50px;
padding: 10px 60px;
white-space: pre-line;
text-align: center;
color: black;
}
<div class="base">HEADING
<span class="base-hover">
<!-- Different style here -->
This is the text under the heading.
<span>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.