How add tooltip in flexdashboard navbar icon? - html

I have this application in R.
How add tooltip when I hover over the icon? Like this:
The icon class is .fa-question-circle. I tried:
HTML:
Text
CSS:
.fa-question-circle
{
position:relative;
}
.fa-question-circle:after
{
background-color:rgba(0, 0, 0, .6);
color: white;
box-sizing:border-box;
content: attr(data-tooltip);
display:none;
padding:5px;
position:absolute;
right: -105px;
bottom: -55px;
z-index:3;
box-shadow: 0 0 3px #000;
border-radius: 0px 10px 10px 10px;
}
.fa-question-circle:hover:after {
display:block;
}
But doesn't work. Thanks.

I found the wrong part. you need use class="fa-question-circle" not class=".fa-question-circle"
.fa-question-circle
{
position:relative;
}
.fa-question-circle:after
{
background-color:rgba(0, 0, 0, .6);
color: white;
box-sizing:border-box;
content: attr(data-tooltip);
display:none;
padding:5px;
position:absolute;
right: -105px;
bottom: -55px;
z-index:3;
box-shadow: 0 0 3px #000;
border-radius: 0px 10px 10px 10px;
}
.fa-question-circle:hover:after {
display:block;
}
Text

You can try something like this and remove . from the class name in your anchor tag.
.fa-question-circle {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.fa-question-circle .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: absolute;
z-index: 1;
}
.fa-question-circle:hover .tooltiptext {
visibility: visible;
}
<a href="#" class="fa-question-circle">Text
<span class="tooltiptext">My text is a text</span>
</a>

Related

Only show box-shadow on part of a side

So I have a header that is shown in the snippet below.
My problem is I only want the shadow around the a tag to show on the part that has expanded out of its container div, to create the impression that the white edge is all one element.
Basically I only want the shadow on the left and on the right to go from the bottom of the a element to the bottom of the div. While also showing on the bottom of the a element.
Screenshot of what I'm after in case my descriptive capabilities are not functioning:
I've tried playing with z-index but haven't been able to get it to work.
My thought with z-index was to push the a behind the div, then pull the img in front of all.
I would prefer a CSS-only solution, as I don't want to have to modify the html, but if I have to I have to.
* {
padding: 0;
margin: 0;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
box-shadow: 0px 0px 5px #000000;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
</div>
Here is box-shadow syntax,
box-shadow: offset-x | offset-y | blur-radius | spread-radius | color
Try reducing it's spread-radius and increase it shadow towards y-axis.
* {
padding: 0;
margin: 0;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
position: relative;
}
a:before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
box-shadow: 0px 0px 5px #000000;
z-index: -1;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
</div>
EDIT:-
Using jquery you can compute the css for span dynamically. Check this.
Html modified, added a <span> below anchor tag and added shadow to the span
* {
padding: 0;
margin: 0;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
/*box-shadow: 0px 0px 5px #000000;*/
z-index:100;
position:absolute;
}
.shadow {
display: inline-block;
margin-left: 30px;
padding: 10px;
margin-top:50px;
height: 10px;
width:120px;
background: white;
box-shadow: 0px 0px 5px #000000;
z-index:0;
position:absolute;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
<span class="shadow">r
</span>
</div>
You can get it by css pseudo element.
Just add css part
a:after {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:5px 5px 5px -5px #000000;
}
a:before {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:-5px 5px 5px -5px #000000;
}
* {
padding: 0;
margin: 0;
box-sizing:border-box;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
position:relative;
/* box-shadow:0px 5px 5px -5px #000000; */
}
a:after {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:5px 5px 5px -5px #000000;
}
a:before {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:-5px 5px 5px -5px #000000;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
</div>

CSS Tooltip (tooltip display even if display none)

I try to make a tooltip (hide/unhide span) when a div is hovered.
I don't know where is the problem because the span is always visible and if i add display:none, all content will be hidden.
Thank you very much!
CSS:
.tooltip {
display:relative;
}
.tooltip span:before {
content:'';
display:none;
border-right: 8px solid #000000;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
position:absolute;
z-index:8;
font-size:0;
line-height:0;
width:0;
height:0;
top: 30%;
left: 83%;
}
.tooltip span:after {
display:none;
position:absolute;
top:0%;
left:89%;
padding:5px 8px;
background: #000000;
color:#fff;
z-index:9;
font-size: 0.75em;
height:auto;
opacity: 0.8;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
white-space:nowrap;
word-wrap:normal;
}
.tooltip span:hover:before,
.tooltip span:hover:after {
display:block;
}
HTML:
<div class="tooltip">
<span>tooltip text</span>
<input type="button" class="button active" value = "HOVER ME" >
</div>
https://jsfiddle.net/dy6bjvbm/1/
Start with something like the following:
.tooltip {
position: relative;
display: inline-block;
}
.tooltip span {
display: none;
position: absolute;
top: 30px;
border: 1px solid #ccc;
padding: 5px;
background: #eee;
}
.tooltip:hover span {
display: block;
}
<div class="tooltip">
<span>tooltip text</span>
<input type="button" class="button active" value = "HOVER ME" >
</div>
See this fork of your fiddle: https://jsfiddle.net/b60fcyu1/
If you're up for a JavaScript/jQuery solution, you can use mouseover and mouseout with hide() and show() element.
$(document).ready(function() {
$("input.button").mouseover(function() {
$('div span').hide();
});
$("input.button").mouseout(function() {
$('div span').show();
});
});
.tooltip {
display: relative;
}
.tooltip span:before {
content: '';
display: none;
border-right: 8px solid #000000;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
position: absolute;
z-index: 8;
font-size: 0;
line-height: 0;
width: 0;
height: 0;
top: 30%;
left: 83%;
}
.tooltip span:after {
display: none;
position: absolute;
top: 0%;
left: 89%;
padding: 5px 8px;
background: #000000;
color: #fff;
z-index: 9;
font-size: 0.75em;
height: auto;
opacity: 0.8;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
white-space: nowrap;
word-wrap: normal;
}
.tooltip span:hover:before,
.tooltip span:hover:after {
display: block;
}
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<div class="tooltip">
<span>tooltip text</span>
<br>
<input type="button" class="button active" value="HOVER ME">
</div>
If you have constant values, you can do it like this. (for more effective with multiple rows)
.tooltip {
position: relative;
width: 300px;
height: 30px;
}
.tooltip span {
opacity: 0;
pointer-events: none;
transition: 0.3s;
width: 100%;
position: absolute;
background-color: rgba(0, 0, 0, 0.6);
color: #ffffff;
line-height: 30px;
bottom: 40px;
border-radius: 5px;
padding: 0 5px;
}
.tooltip span:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 0, 0, 0);
border-top-color: rgba(0, 0, 0, 0.6);
border-width: 6px;
margin-left: -6px;
}
.tooltip:hover span {
opacity: 1;
pointer-events: inherit;
}
<p style="height:100px;">
<!-- for seperate -->
</p>
<div class="tooltip">
<span>tooltip text tooltip text tooltip text tooltip text tooltip text tooltip text tooltip text tooltip text</span>
<input type="button" class="button active" value="HOVER ME" style="width:100%;height:30px">
</div>

How to style the background of the parent element when hovering more then one child element?

According to a trick found in Stack overflow, I can change the background of the parent element hovering a child like this:
parent sibling { }
parent sibling:hover { }
parent:hover sibling { }
But I need to change the background color hovering different child elements. For example, hovering the Facebook button, the background goes blue, while hovering the Google + button, the backgroud goes red.
I've tried this:
<div class="share_box">
<div class="white-container">
<div class="facebook-sibling"/>
<a class="facebook-child-button"/>
<div class="twitter-sibling"/>
<a class="twitter-child-button"/>
<div class="googleplus-sibling"/>
<a class="googleplus-child-button"/>
</div>
</div>
but for multiple buttons it didn't work. The result I expect is similar to:
If you set the parent position: relative, it will contain any position: absolute children.
Create a new element inside the end of the parent, then make it position: absolute and position and size it so that it fills the parent.
Then use z-index: -1 to set it behind the rest of the content (e.g. the buttons).
Then you can use the General Sibling Combinator (~) to select the new element after the hovered element.
.facebook:hover ~ .background { background-color: rgb(50, 100, 150); }
.twitter:hover ~ .background { background-color: rgb(50, 150, 250); }
.google:hover ~ .background { background-color: rgb(250, 75, 50); }
.share {
position: relative;
}
.background {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -1;
} /* Following styling for demo purposes only, not relevant */ .facebook:before { background-position:-46px -28px; width:101px; } .twitter:before { background-position:-151px -28px; width:90px; } .google:before { background-position:-245px -28px; width:94px; } .button:before { display:inline-block; content: ""; height:36px; background-image:url("http://i.stack.imgur.com/AXvMk.png"); border-radius: 3px; box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.2); } .button { display:inline-block; padding: 2px; } .white-container { padding: 10px 20px; font-size: 0; background: #fff; border-radius: 3px; } .background { background: #fff; } body { margin: 0 4px; border: 1px solid #aaa; border-top: 0px; box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.1) } .share { padding: 10px 15px; box-shadow: 0px 5px 5px -5px rgba(0,0,0,0.3) inset } body:before { content: ''; height: 4px; display: block; background: #fff; border-bottom: 1px solid #aaa } html { background: #efefef }
<div class="share">
<div class="white-container">
<div class="background"></div>
</div>
</div>
Is this what you want?
DEMO 1: http://jsfiddle.net/t73431y8/
DEMO 2: http://jsfiddle.net/t73431y8/2/
HTML:
<div class="PARENT">
<div class="RED">RED</div>
<div class="BLUE">BLUE</div>
<div class="GREEN">GREEN</div>
</div>
CSS:
.PARENT{
position: relative;
}
.RED{
display: inline-block;
margin: 5px;
padding: 5px;
color: #BB0000;
background: #FFF;
}
.RED:hover:after{
display: block;
width: 100%;
height: 100%;
background: #BB0000;
position: absolute;
top: 0px;
left: 0px;
content: ' ';
z-index: -1;
}
.BLUE{
display: inline-block;
margin: 5px;
padding: 5px;
color: #0000BB;
background: #FFF;
}
.BLUE:hover:after{
display: block;
width: 100%;
height: 100%;
background: #0000BB;
position: absolute;
top: 0px;
left: 0px;
content: ' ';
z-index: -1;
}
.GREEN{
display: inline-block;
margin: 5px;
padding: 5px;
color: #00BB00;
background: #FFF;
}
.GREEN:hover:after{
display: block;
width: 100%;
height: 100%;
background: #00BB00;
position: absolute;
top: 0px;
left: 0px;
content: ' ';
z-index: -1;
}

Best way to Convert HTML Button to a Link

I have the following code where I have a Button that has the arrow hack. The only issue is I'd like to have this display the link on the status bar. A button does not achieve. How do I convert this to a a href link and still be able to keep that arrow? Here is my code:
JSFIDDLE
HTML:
<button type="button" class="btn-lg btn-default my-button my-button-active">My Button</button>
CSS:
.my-button {
color: #fff ;
background-color: #444346;
font-size:15px;
padding: 20px 0px;
border:none;
margin-right:20px;
position: relative;
outline:0;
width:31%;
}
.my-button-active:after {
content:'';
position: absolute;
top: 100%;
left: 50%;
margin-left: -10px;
width: 0;
height: 0;
border-top: solid 7px #444346;
border-left: solid 7px transparent;
border-right: solid 7px transparent;
}
.my-button-active:hover:after {
content:'';
position: absolute;
top: 100%;
left: 50%;
margin-left: -10px;
width: 0;
height: 0;
border-top: solid 7px #e6e6e6;
border-left: solid 7px transparent;
border-right: solid 7px transparent;
}
It is very simple. Just convert the button to a and add display: block; or display: inline-block; to the class .my-button.
Fiddle link: http://jsfiddle.net/samirkumardas/60n0ruyj/2/
Change your html to an anchor tag:
<a class="btn-lg btn-default my-button my-button-active" href="">My Button that links to some other page</a>
Replace your .my-button selector with:
.my-button {
display: block;
position: relative;
color: #fff;
background-color: #444346;
font-size:15px;
padding: 20px 0;
text-align: center;
border: none;
margin-right: 20px;
outline: 0;
width: 31%;
}
Just change your button to an anchor and adjust your css.
div {
margin: 30px;
}
a.my-button {
color: #fff ;
background-color: #444346;
font-size:15px;
padding: 20px 0px;
border:none;
margin-right:20px;
position: relative;
outline:0;
width:31%;
display: inline-block;
text-align: center;
}
.my-button:hover {
text-decoration: none;
}
.my-button-active:after {
content:'';
position: absolute;
top: 100%;
left: 50%;
margin-left: -10px;
width: 0;
height: 0;
border-top: solid 7px #444346;
border-left: solid 7px transparent;
border-right: solid 7px transparent;
}
.my-button-active:hover:after {
content:'';
position: absolute;
top: 100%;
left: 50%;
margin-left: -10px;
width: 0;
height: 0;
border-top: solid 7px #e6e6e6;
border-left: solid 7px transparent;
border-right: solid 7px transparent;
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div>
My Button that links to some other page
</div>
After changing your <button> tag to an <a> tag, the key thing is to have display: block; applied to it, as <a> tags are primarily inline elements and cannot have padding and margin.

CSS hover bubble does not seem out

Hello friends I have a problem with mouse hover on a div.
I have created this DEMO from codepen.io
So you can see in this demo when you hover over image the bubble will be shown. But the bubble does not seem out.
Here is the HTML code:
<div class="container"
<div class="present_wrp">
<div class="wo_wrp2 wo-wrp2">
<div class="wo_content2">
<div class="ornekoto"><img src="http://cdn.flaticon.com/png/256/26625.png" width="267" height="250" /><div class="ornot"></div></div>
</div>
</div>
</div>
</div>
and the CSS code:
.container {
margin:0px auto;
width:500px;
height:500px;
margin-top:100px;
}
.wo_wrp *:last-child {
margin-bottom: 0;
}
.wo-wrp2 {
float: left;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
position: relative;
width: 300px;
}
.wo_content2 {
background: none repeat scroll 0 0 #FFFFFF;
background-color: #fff;
padding: 15px;
position: relative;
z-index: 1;
overflow:hidden;
border: 1px solid #97a8bb;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius:3px;
}
.wo_content_t2 {
background: none repeat scroll 0 0 #FFFFFF;
background-color: #fff;
padding:5px;
position: relative;
z-index: 1;
overflow:hidden;
border: 1px solid #97a8bb;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius:3px;
}
.wo-wrp2:after {
border-radius: 0 0 50% 50% / 0 0 20px 20px;
bottom: 0;
box-shadow: 0 10px 10px rgba(113, 145, 182, 0.5);
content: "";
height: 20px;
left: 10px;
position: absolute;
right: 10px;
}
.ornekoto{
float:left;
width:267px;
height:250px;
background-color:#307cdc;
border-radius:3px;
-webkit-border-radius:3px;
-o-border-radius:3px;
-o-border-radius:3px
}
.ornot
{
position: absolute;
width: 400px;
height: 500px;
padding: 0px;
background: #307cdc;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
display:none;
margin-top:-755px;
}
.ornot:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 15px 15px 0;
border-color: #307cdc transparent;
display: block;
width: 0;
z-index: 1;
bottom: -15px;
left: 58px;
}
.ornekoto:hover .ornot{
display:block;
}
The problem is that you have overflow:hidden; set. If you swap that for a clearfix it will work fine.
Overflow hidden is keeping the height of the container, so you need to first add a clearfix to the div (a clearfix allows the div to keep the height of the floated elements within it).
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
Next all you need to do is to add this to the surrounding div:
<div class="wo_content2 cf">
And then remove the overflow hidden property
.wo_content2{
overflow:hidden;
}
Demo here:
http://codepen.io/EightArmsHQ/pen/NPbKpz
You're setting overflow: hidden on .wo_content2 which prevents your bubble from popping out of it's parent container (because the "overflow" is hidden). Use a clearfix instead:
.wo_content2 {
background: none repeat scroll 0 0 #FFFFFF;
background-color: #fff;
padding: 15px;
position: relative;
z-index: 1;
/*overflow:hidden;*/ <---------- remove
border: 1px solid #97a8bb;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius:3px;
}
.wo_content2:after {
content: '';
display: block;
clear: both;
}
CODEPEN