Remove underline and link from tooltip
I try to implement a tooltip with picture. That works. But I have 2 problems:
- If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).
- I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.
HTML:
<div class="col-lg-4">
<a href="#">
<div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
</a>
</div>
CSS:
a .hover-img {
position:relative;
}
a .hover-img span {
position:absolute; left:-9999px; top:-9999px; z-index:9999;
border: 2px solid #000;
}
a:hover .hover-img span {
top: 40px;
left: 0;
}
.dotted {
color: #4e555b;
border-bottom: 2px dashed #4e555b;
text-decoration: none!important;
}
.dotted:hover {
text-decoration: none!important;
}
JSFiddle:
https://jsfiddle.net/kdzb108h/
html css
add a comment |
I try to implement a tooltip with picture. That works. But I have 2 problems:
- If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).
- I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.
HTML:
<div class="col-lg-4">
<a href="#">
<div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
</a>
</div>
CSS:
a .hover-img {
position:relative;
}
a .hover-img span {
position:absolute; left:-9999px; top:-9999px; z-index:9999;
border: 2px solid #000;
}
a:hover .hover-img span {
top: 40px;
left: 0;
}
.dotted {
color: #4e555b;
border-bottom: 2px dashed #4e555b;
text-decoration: none!important;
}
.dotted:hover {
text-decoration: none!important;
}
JSFiddle:
https://jsfiddle.net/kdzb108h/
html css
add a comment |
I try to implement a tooltip with picture. That works. But I have 2 problems:
- If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).
- I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.
HTML:
<div class="col-lg-4">
<a href="#">
<div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
</a>
</div>
CSS:
a .hover-img {
position:relative;
}
a .hover-img span {
position:absolute; left:-9999px; top:-9999px; z-index:9999;
border: 2px solid #000;
}
a:hover .hover-img span {
top: 40px;
left: 0;
}
.dotted {
color: #4e555b;
border-bottom: 2px dashed #4e555b;
text-decoration: none!important;
}
.dotted:hover {
text-decoration: none!important;
}
JSFiddle:
https://jsfiddle.net/kdzb108h/
html css
I try to implement a tooltip with picture. That works. But I have 2 problems:
- If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).
- I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.
HTML:
<div class="col-lg-4">
<a href="#">
<div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
</a>
</div>
CSS:
a .hover-img {
position:relative;
}
a .hover-img span {
position:absolute; left:-9999px; top:-9999px; z-index:9999;
border: 2px solid #000;
}
a:hover .hover-img span {
top: 40px;
left: 0;
}
.dotted {
color: #4e555b;
border-bottom: 2px dashed #4e555b;
text-decoration: none!important;
}
.dotted:hover {
text-decoration: none!important;
}
JSFiddle:
https://jsfiddle.net/kdzb108h/
html css
html css
asked Jan 19 at 20:31
StampyStampy
165318
165318
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
Add this:
a {
text-decoration: none;
}
text-decoration
should be applied directly to <a>
, not to its child tags.
Refer to: https://jsfiddle.net/ewtysb4c/
add a comment |
The word is underlined because the <a>
tag has a href
attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.
However, the cursor will also not behave like a link. You could enforce the text-decoration: none
in the <a>
tag and add a cursor: pointer
to the the a:hover
rules. I'd suggest you create an a.tooltip-link
class and add these styles to it so they won't be applied to all <a>
tags in your page.
add a comment |
- The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.
add a comment |
So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
Second thing. I'd rather make the structure next way:
<div class="wrapper objects">
<div class="object">
<p class="tooltip-provoke">Tooltip Text</p>
<div class="tooltip-text">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
Than set div.tooltip-text display:block
, and change it by hovering p.tooltip-provoke
. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
You can see example here: https://jsfiddle.net/0pmknx4g/9/
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54271125%2fremove-underline-and-link-from-tooltip%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Add this:
a {
text-decoration: none;
}
text-decoration
should be applied directly to <a>
, not to its child tags.
Refer to: https://jsfiddle.net/ewtysb4c/
add a comment |
Add this:
a {
text-decoration: none;
}
text-decoration
should be applied directly to <a>
, not to its child tags.
Refer to: https://jsfiddle.net/ewtysb4c/
add a comment |
Add this:
a {
text-decoration: none;
}
text-decoration
should be applied directly to <a>
, not to its child tags.
Refer to: https://jsfiddle.net/ewtysb4c/
Add this:
a {
text-decoration: none;
}
text-decoration
should be applied directly to <a>
, not to its child tags.
Refer to: https://jsfiddle.net/ewtysb4c/
answered Jan 19 at 20:42
AjitZeroAjitZero
119212
119212
add a comment |
add a comment |
The word is underlined because the <a>
tag has a href
attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.
However, the cursor will also not behave like a link. You could enforce the text-decoration: none
in the <a>
tag and add a cursor: pointer
to the the a:hover
rules. I'd suggest you create an a.tooltip-link
class and add these styles to it so they won't be applied to all <a>
tags in your page.
add a comment |
The word is underlined because the <a>
tag has a href
attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.
However, the cursor will also not behave like a link. You could enforce the text-decoration: none
in the <a>
tag and add a cursor: pointer
to the the a:hover
rules. I'd suggest you create an a.tooltip-link
class and add these styles to it so they won't be applied to all <a>
tags in your page.
add a comment |
The word is underlined because the <a>
tag has a href
attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.
However, the cursor will also not behave like a link. You could enforce the text-decoration: none
in the <a>
tag and add a cursor: pointer
to the the a:hover
rules. I'd suggest you create an a.tooltip-link
class and add these styles to it so they won't be applied to all <a>
tags in your page.
The word is underlined because the <a>
tag has a href
attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.
However, the cursor will also not behave like a link. You could enforce the text-decoration: none
in the <a>
tag and add a cursor: pointer
to the the a:hover
rules. I'd suggest you create an a.tooltip-link
class and add these styles to it so they won't be applied to all <a>
tags in your page.
answered Jan 19 at 20:45
Guilherme VieiraGuilherme Vieira
596
596
add a comment |
add a comment |
- The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.
add a comment |
- The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.
add a comment |
- The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.
- The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.
answered Jan 19 at 20:39
Matthew PageMatthew Page
592112
592112
add a comment |
add a comment |
So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
Second thing. I'd rather make the structure next way:
<div class="wrapper objects">
<div class="object">
<p class="tooltip-provoke">Tooltip Text</p>
<div class="tooltip-text">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
Than set div.tooltip-text display:block
, and change it by hovering p.tooltip-provoke
. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
You can see example here: https://jsfiddle.net/0pmknx4g/9/
add a comment |
So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
Second thing. I'd rather make the structure next way:
<div class="wrapper objects">
<div class="object">
<p class="tooltip-provoke">Tooltip Text</p>
<div class="tooltip-text">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
Than set div.tooltip-text display:block
, and change it by hovering p.tooltip-provoke
. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
You can see example here: https://jsfiddle.net/0pmknx4g/9/
add a comment |
So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
Second thing. I'd rather make the structure next way:
<div class="wrapper objects">
<div class="object">
<p class="tooltip-provoke">Tooltip Text</p>
<div class="tooltip-text">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
Than set div.tooltip-text display:block
, and change it by hovering p.tooltip-provoke
. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
You can see example here: https://jsfiddle.net/0pmknx4g/9/
So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
Second thing. I'd rather make the structure next way:
<div class="wrapper objects">
<div class="object">
<p class="tooltip-provoke">Tooltip Text</p>
<div class="tooltip-text">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
Than set div.tooltip-text display:block
, and change it by hovering p.tooltip-provoke
. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
You can see example here: https://jsfiddle.net/0pmknx4g/9/
answered Jan 19 at 21:16
NikitaNikita
614
614
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54271125%2fremove-underline-and-link-from-tooltip%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown