Good Morning,
I have this line of code:
<div class="navigation">
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div>
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div></div>
What I am trying to do is have the help-tip div go right next to the link. The paragraph appears when you put your mouse over the help-tip div. I am looking to get the paragraph to go directly under the help-tip icon in short of an overlay style. When I remove the position absolute for the both elements the icon goes right next to the icon and the paragraph goes under the icon, but it creates a massive amount of space.
Here is my css
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{ /* The tooltip */
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 300px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.help-tip p:after{ /* Prevents the tooltip from being hidden */
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}
and here is a jfiddle
https://jsfiddle.net/13275tvz/1/
Need some HTML and CSS Fix
When you are making the element position absolute, make sure it's parent have the position relative property.
HTML
<div class="navigation">
<div class="link-container">
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div>
</div>
<div class="link-container">
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div></div>
</div>
CSS
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.link-container{
position:relative;
display:inline-block;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{ /* The tooltip */
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 300px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.help-tip p:after{ /* Prevents the tooltip from being hidden */
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}
Style Accordingly..
Link for reference
hope this helps..
you need change position to relative, display to inline-block and desmiss top, right.
.help-tip {
position: relative;
/* top: 18px; */
/* right: 18px; */
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
display: inline-block;
}
Related
I have a HTML form with some questions and a select tag for the answers.
I'd like to explain those answers with a tooltip.
HTML
<div id="domanda">
<div class="help-tip">
<p> some text</p></div>
This is the question:
</div><div id="scelte">
<select name="finalita">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
</select></div>
CSS
#domanda{
font-size: 18px;
}
#scelte{
margin-bottom: 30px;
}
.help-tip{
display: inline-block;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: pointer;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display: block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{ /* The tooltip */
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 800px;
position: right;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 15px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
display: none;
}
.help-tip p:after{ /* Prevents the tooltip from being hidden */
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}
The issue is that is showing also what's under the tooltip paragraph as you can see here
This is the picture when the mouse is not hovering
I spent a while tryin to fix it but without success. What's wrong with my css?
Adding position: relative; to the .help-tip:hover p fixed it.
Thanks to vssadineni
I am developing interactive map. I have svg vector map itself and different buttons(divs with link inside), styled as circles. Vector, buttons and pop-ups are nested in div "map". The click on button link opens the pop-up with text. The problem is: I cannot center-align the link text on a button.Text is centered, but sticks at the top of the button. I have tried to nest link inside button with same styling as my "div variant" has now - that is the only way i get normal centered link texts. But such way is invalid - doesnt work for IE and moz
.button-my{width:25px;
height:25px;
border-radius: 50%;
text-decoration:none;
background: #FFC651 !important ;
text-align: center;
color: #FFC651 !important;
font-family: 'Roboto', sans-serif !important;;
font-size: 20%;
top: 34%;
left: 49%;
position: absolute;
margin: 0 !important;
padding: 0 !important;
border: none !important;
-webkit-animation: rainbow 2s infinite;}
#-webkit-keyframes rainbow {
0% {opacity: 1}
50% {opacity: 0.5}
100% {opacity: 1}
}
.button-my:hover {
transform: scale(4);
transition: all .5s ease-in-out;
z-index: 5;
-webkit-animation: none;
}
.my{
display: inline-block;
top: 33%;
left: 45%;
background-color: #00C3D1;
opacity: 0.5;
position: absolute;
padding: 0,5%;
visibility: hidden;
opacity: 0;
width:10%;
border-radius: 5%;
transition: opacity 800ms;
z-index: 5;
}
.my:target {
visibility: visible;
opacity: 0.9;
}
a{
text-decoration: none;
color: white !important;
padding: 0 !important;
text-align: center !important;
margin: auto;
}
a:hover{
text-decoration: underline;
}
div{
z-index: 5;
}
.map{
position: relative;
margin-left: auto;
margin-right: auto;
}
<div class="map"><img src="../img/graph.svg">
<div class="button-my">Text</button>
<div class="my" id="my"><a href="
http://www.my.com" target="_blank"><h1>Random pop-up text</h1>
</a>
<a class="close" href="#">×</a>
</div></div>
You need to either increase the line-height to 25px so it fills the height of the button, or increase the top padding to push the text down into position.
You should almost always avoid using height in CSS. In this case, it's better to change the height of the contents to achieve the height you want... then the height of the button will be determined from that (line-height + top padding + bottom padding).
.button-my {
width: 25px;
height: 25px;
line-height: 25px;
...
}
add line height to a
.button-my a{
line-height: 25px;
}
.button-my{width:25px;
height:25px;
border-radius: 50%;
text-decoration:none;
background: #FFC651 !important ;
text-align: center;
color: #FFC651 !important;
font-family: 'Roboto', sans-serif !important;;
font-size: 20%;
top: 34%;
left: 49%;
position: absolute;
margin: 0 !important;
padding: 0 !important;
border: none !important;
-webkit-animation: rainbow 2s infinite;}
#-webkit-keyframes rainbow {
0% {opacity: 1}
50% {opacity: 0.5}
100% {opacity: 1}
}
.button-my:hover {
transform: scale(4);
transition: all .5s ease-in-out;
z-index: 5;
-webkit-animation: none;
}
.button-my a{
line-height: 25px;
}
.my{
display: inline-block;
top: 33%;
left: 45%;
background-color: #00C3D1;
opacity: 0.5;
position: absolute;
padding: 0,5%;
visibility: hidden;
opacity: 0;
width:10%;
border-radius: 5%;
transition: opacity 800ms;
z-index: 5;
}
.my:target {
visibility: visible;
opacity: 0.9;
}
a{
text-decoration: none;
color: white !important;
padding: 0 !important;
text-align: center !important;
margin: auto;
}
a:hover{
text-decoration: underline;
}
div{
z-index: 5;
}
.map{
position: relative;
margin-left: auto;
margin-right: auto;
}
<div class="map"><img src="../img/graph.svg">
<div class="button-my">Text</button>
<div class="my" id="my"><a href="
http://www.my.com" target="_blank"><h1>Random pop-up text</h1>
</a>
<a class="close" href="#">×</a>
</div></div>
I am using css to create tooltip, 4 tooltips are placed sequentially, 2nd tooltip appears on the popup content of 1st tooltip
The following code is placed in between jsp file in liferay, every jsp file has the tooltip code in it. If I open the 1st tooltip, other tooltips appear on the popup content of 1st tooltip,
I need to show the popup contents without any interruption. How do I do that?
My code is
.help-tip {
position: absolute;
top: 34px;
right: 120px;
text-align: center;
background-color: #a3c2c2;
border-radius: 50%;
width: 14px;
height: 10px;
font-size: 10px;
line-height: 16px;
cursor: default;
}
.help-tip:before {
content: '?';
font-weight: normal;
font-size: 10px;
color: #fff;
}
.help-tip:hover p {
display: block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p {
/* The tooltip */
display: none;
text-align: center;
/*background-color: #a3c2c2;*/
padding: 5px;
width: 170px;
position: absolute;
border-radius: 6px;
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.4);
right: -100px;
/*color: #000000;*/
font-size: 14px;
line-height: 1.4;
color: #000000;
background: #FBF5E6;
background: -webkit-linear-gradient(top, #FBF5E6, #FFFFFF);
background: linear-gradient(top, #FBF5E6, #FFFFFF);
border: 1px solid #CFB57C;
}
.help-tip p:before {
/* The pointer of the tooltip */
position: absolute;
content: '';
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom-color: #66ccff;
right: 100px;
top: -12px;
}
.help-tip p:after {
/* Prevents the tooltip from being hidden */
width: 100%;
height: 40px;
content: '';
position: absolute;
top: -40px;
left: 0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
transform: scale(0.6);
}
100% {
opacity: 100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
<div class="help-tip">
<p>This is the inline edit help tip!</p>
</div>
Due to using the exact same code for each tooltip, every tooltip will have the CSS property, position: absolute; and that could be causing the problem. Try changing all the positions to relative.
How to add TEXT in the image...so that the TEXT is view-able only when the image becomes dark when mouse is placed over it.. something like ..the one given in the example image below...
Thanks for your help.
.image {
width: 250px;
height: 200px;
background: black;
position: relative;
overflow: hidden;
}
.image img {
transition: all ease 1s;
}
.image:hover img { /* Darkening effect on mouseover */
background: black;
opacity: 0.7;
}
.image .arrow { /* Creates a half triangle with top and left arrow transparent */
opacity: 0;
border-color: transparent #f2f2f2 #f2f2f2 transparent;
transition: all ease 1s;
position: relative;
}
.image:hover .arrow { /* Mouseover effect */
opacity: 1;
font-family: Roboto;
font-size: 36px;
text-align: center;
border-image: none;
border-style: solid;
border-width: 45px;
position: absolute;
bottom: 0;
font-weight: normal;
width: 0;
height: 0;
right: 0;
}
.image:hover .arrow {
border-image: none;
border-style: solid;
border-width: 45px;
bottom: 0;
display: block;
font-family: Roboto;
font-size: 36px;
font-weight: normal;
height: 0;
opacity: 1;
position: absolute;
right: 0;
text-align: center;
width: 0;
}
.image .arrow {
border-color: transparent #f2f2f2 #f2f2f2 transparent;
opacity: 0;
position: relative;
transition: all 1s ease 0s;
}
.image .arrow span {
left: 5px;
position: relative;
top: -10px;
}
<div class="image">
<img src="http://lorempixel.com/250/200/sports" />
<div class="arrow"><span>></span></div>
</div>
enter image description here
It's simple. Create some text inside your wrapper div, then order the text to display on hovering the wrapper. Below is a demo of this logic.
The HTML:
<div class="image">
<p>I'm some very interesting text!</p>
<div class="arrow"><span>></span></div>
</div>
The CSS:
p{
color: #fff;
opacity: 0;
font-weight: bold;
text-align: center;
font-size:32px;
color: red;
/* bring your own prefixes */
transform: translate(0, 50%);
transition: all .5 ease;
}
.image:hover p {
visibility: visible;
opacity: 1;
}
CODEPEN DEMO
i think you can create like this
you need to change the position of the .image class so that text div can appear overlap on that
.image-hover-wrapper {
display:none;
text-align: center;
width: 250px;
color: red;
font-size: 35px;
position: relative;
top: -125px;
background: rgba(255,255,255,0.6);
}
.image:hover > .image-hover-wrapper{
display:block;
opacity:0.8;
transition-property: animation;
transition-duration: 2s;
transition-timing-function: linear;
}
<div class="image">
<img src="http://lorempixel.com/250/200/sports" />
<div class="arrow"><span></span></div>
<div class="image-hover-wrapper">
Hii
</div>
</div>
and here is the
Updated DEmo
There are plenty of JavaScript-based libraries that show tooltips when you hover your mouse over a certain area of a web page. Some are rather plain, some allow the tooltip to display HTML content styled with CSS.
But is there a way to show a styled tooltip without using JavaScript? If you just use the title attribute, tags are not processed (e.g. foo<br />bar doesn't produce a line break). I'm looking for a solution that allows one to display styled HTML content without using any JavaScript.
I have made a little example using css
.hover {
position: relative;
top: 50px;
left: 50px;
}
.tooltip {
/* hide and position tooltip */
top: -10px;
background-color: black;
color: white;
border-radius: 5px;
opacity: 0;
position: absolute;
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.hover:hover .tooltip {
/* display tooltip on hover */
opacity: 1;
}
<div class="hover">hover
<div class="tooltip">asdadasd
</div>
</div>
FIDDLE
http://jsfiddle.net/8gC3D/471/
Using the title attribute:
Link
Similar to koningdavid's, but works on display:none and block, and adds additional styling.
div.tooltip {
position: relative;
/* DO NOT include below two lines, as they were added so that the text that
is hovered over is offset from top of page*/
top: 10em;
left: 10em;
/* if want hover over icon instead of text based, uncomment below */
/* background-image: url("../images/info_tooltip.svg");
/!* width and height of svg *!/
width: 16px;
height: 16px;*/
}
/* hide tooltip */
div.tooltip span {
display: none;
}
/* show and style tooltip */
div.tooltip:hover span {
/* show tooltip */
display: block;
/* position relative to container div.tooltip */
position: absolute;
bottom: 1em;
/* prettify */
padding: 0.5em;
color: #000000;
background: #ebf4fb;
border: 0.1em solid #b7ddf2;
/* round the corners */
border-radius: 0.5em;
/* prevent too wide tooltip */
max-width: 10em;
}
<div class="tooltip">
hover_over_me
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis purus dui. Sed at orci. </span>
</div>
This one is very interesting,
HTML and CSS only
.help-tip {
position: absolute;
top: 18px;
left: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before {
content: '?';
font-weight: bold;
color: #fff;
}
.help-tip:hover span {
display: block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip span {
display: none;
text-align: left;
background-color: #1E2021;
padding: 5px;
width: 200px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
left: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip span:before {
position: absolute;
content: '';
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom-color: #1E2021;
left: 10px;
top: -12px;
}
.help-tip span:after {
width: 100%;
height: 40px;
content: '';
position: absolute;
top: -40px;
left: 0;
}
<span class="help-tip">
<span > This is the inline help tip! </span>
</span>
Pure CSS:
.app-tooltip {
position: relative;
}
.app-tooltip:before {
content: attr(data-title);
background-color: rgba(97, 97, 97, 0.9);
color: #fff;
font-size: 12px;
padding: 10px;
position: absolute;
bottom: -50px;
opacity: 0;
transition: all 0.4s ease;
font-weight: 500;
z-index: 2;
}
.app-tooltip:after {
content: '';
position: absolute;
opacity: 0;
left: 5px;
bottom: -16px;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent rgba(97, 97, 97, 0.9) transparent;
transition: all 0.4s ease;
}
.app-tooltip:hover:after,
.app-tooltip:hover:before {
opacity: 1;
}
<div href="#" class="app-tooltip" data-title="Your message here"> Test here</div>
Another similar way to do it with CSS:
#img { }
#img:hover {visibility:hidden}
#thistext {font-size:22px;color:white }
#thistext:hover {color:black;}
#hoverme {width:50px;height:50px;}
#hoverme:hover {
background-color:green;
position:absolute ;
left:300px;
top:100px;
width:40%;
height:20%;
}
<p id="hoverme"><img id="img" src="http://a.deviantart.net/avatars/l/o/lol-cat.jpg"></img><span id="thistext">LOCATZ!!!!</span></p>
Try the Js Fiddle
Here are some links about transitions and other ways to do it:
http://www.w3schools.com/css3/css3_transitions.asp
http://dev.opera.com/articles/view/css3-show-and-hide/
You can use the title attribute, e.g. if you want to have a Tooltip over a text, just make:
<span title="This is a Tooltip">This is a text</span>
This is my solution for this:
https://gist.github.com/BryanMoslo/808f7acb1dafcd049a1aebbeef8c2755
The element recibes a "tooltip-title" attribute with the tooltip text and it is displayed with CSS on hover, I prefer this solution because I don't have to include the tooltip text as a HTML element!
#HTML
<button class="tooltip" tooltip-title="Save">Hover over me</button>
#CSS
body{
padding: 50px;
}
.tooltip {
position: relative;
}
.tooltip:before {
content: attr(tooltip-title);
min-width: 54px;
background-color: #999999;
color: #fff;
font-size: 12px;
border-radius: 4px;
padding: 9px 0;
position: absolute;
top: -42px;
left: 50%;
margin-left: -27px;
visibility: hidden;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:after {
content: "";
position: absolute;
top: -9px;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #999999 transparent transparent;
visibility: hidden;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:hover:before,
.tooltip:hover:after{
visibility: visible;
opacity: 1;
}