Hover over span to get tool tip div - html

Do you guys know how I can get my tooltip to show up if I hover my mouse over the span icon I created only using css?
HTML
<div>
<div class="t-hover-block">
This is the tooltip!
</div>
<span class="i-q-mark"></span>
</div>
CSS
.t-hover-block {
opacity: 0;
position: absolute;
background: rgba(0, 0, 0, 0.3);
border-radius: 1.429em;
font-size: 10pt;
padding: 0.929em;
width: 16em;
top: 40.4%;
left: 61%;
text-align: left;
background: rgba(255, 255, 255, 1);
box-shadow: 4px 3px 34px -3px rgba(245, 188, 223, 1);
&:hover {
opacity: 1;
}
}
.t-hover-block::after {
background-color: rgba(255, 255, 255, 1);
content: '\00a0';
height: 0.857em;
width: 1.071em;
position: absolute;
top: 40%;
left: 97%;
transform: rotate(29deg) skew(-35deg);
border: solid 1px rgba(181, 49, 134, 0.3);
border-left: none;
border-bottom: none;
}
.i-q-mark {
display: inline-block;
width: 2em;
height: 2em;
background-color: $color-brand;
border-radius: 50%;
text-align: center;
margin-top: 0.643em;
margin-left: 0.714em;
line-height: 2.071em;
&:after {
font-family: 'Raleway';
content: '\3F'; // Hex value for question mark
color: #ffffff;
font-size: 16pt;
font-weight: 700;
}
}
I can get this to work but only if it hovers over the div and that's not the behavior needed. As a side question is this structure the best way of doing that I want to achieve?

If you flip the order of the div and span, and use this css for the hover state, you can get what you are looking for:
.i-q-mark:hover + .t-hover-block {
opacity: 1;
}
the HTML:
<div>
<span class="i-q-mark">Span</span>
<div class="t-hover-block">
This is the tooltip!
</div>
</div>
Using the adjacentsibling selector + you can target the next element

Related

Why is transform-origin: bottom not working?

I'm trying to get a line appear "under" an input box when in focus. For some reason transform-origin "left" (that is if I change it to "right" it will appear from the right side, but with "left" it appears from the left) works but 'bottom' doesn't and it keeps appearing on top.
.wrap-input{
width: 100%;
position: relative;
border-bottom: 2px solid #adadad;
height: 49px;
}
.inputForm {
font-size: 15px;
color: #555555;
line-height: 1.2;
display: block;
width: 100%;
height: 45px;
padding: 0 5px;
outline: none;
border: none;
}
.wrap-input::before{
content: '';
height: 2px;
background: linear-gradient(90deg, rgba(128,0,0,1) 15%, rgba(238,174,150,1) 49%, rgba(128,0,0,1) 85%);
display: block;
transform: scale(0, 1);
transition: transform 0.4s cubic-bezier(1, 0, 0, 1);
transform-origin: left bottom;/*this line is problem*/
}
.wrap-input:hover::before {
transform: scale(1, 1)
}
<div class="wrap-input" data-validate="Valid email is: info#johndoe.com">
<input class="inputForm" type="text" name="email" placeholder="Email">
</div>
I suspect that transform-origin isn't what you require - it tells the system the point from which any tranformation is to take place - it's relative to the element it's in, not to any 'owner'/parent/ancestor.
To position the pseudo element under the input element this snippet gives it position absolute and position left 0 and bottom 0 - these are relative to the actual div itself.
.wrap-input {
width: 100%;
position: relative;
border-bottom: 2px solid #adadad;
height: 49px;
}
.inputForm {
font-size: 15px;
color: #555555;
line-height: 1.2;
display: block;
width: 100%;
height: 45px;
padding: 0 5px;
outline: none;
border: none;
}
.wrap-input::before {
content: '';
height: 2px;
background: linear-gradient(90deg, rgba(128, 0, 0, 1) 15%, rgba(238, 174, 150, 1) 49%, rgba(128, 0, 0, 1) 85%);
display: block;
transform: scale(0, 1);
transition: transform 0.4s cubic-bezier(1, 0, 0, 1);
transform-origin: left center;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
}
.wrap-input:hover::before {
transform: scale(1, 1)
}
<div class="wrap-input" data-validate="Valid email is: info#johndoe.com">
<input class="inputForm" type="text" name="email" placeholder="Email">
</div>

How to align text in input on top of div

When putting a div behind another div the text in bot div elements is aligned.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-size: 24px;
font-family: Verdana;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<div type="text" class="box top">20-123</div>
<div class="box underlayer">20-123-20</div>
</div>
When the div with class top is replaced with an input, the text is 1px off, though the border is still aligned correctly.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-family: Verdana;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<div class="box underlayer">20-123-20</div>
</div>
I can't put my head around it. Somebody here to explain it and suggest how to resolve this ?
This happens because of how inputs are handled. The textfield inside an input-element is streched to fit the box size. In this case 34px. So the fix is to increase the div's line-height to match the 34px of the input.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-family: Verdana!important;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
line-height: 34px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<div class="box underlayer">20-123-20</div>
</div>
You have a problem with your fonts.
You have one font for the underlayer and one for the other.
I also add a font-size and hide your second box so you can move the top position of your underlayer to match with the text on top.
It's probably not the best way to do it, but it works.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
font-family: sans-serif;
z-index: 2;
position: relative;
}
.underlayer {
font-family: sans-serif;
font-size: 24px;
top: -44px;
left: 1px;
z-index: 1;
border: 0px solid #cccccc;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<div class="box underlayer">20-123-20</div>
</div>
How to resolve it is here:
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
display: block;
tabindex: -1;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<input class="box underlayer" value="20-123-20">
</div>
You change underlayer from div to input. It changes second div's font to the one used by inputs. Because underlayer has lower z-index, it will never be selected by user, no it doesn't create any danger. You also set second input's display to block.
Unfortunately, I don't know why it originally happened, so I can't explain it.

Need help in making the left side of the button flow left

I am pretty new in web development and I am trying to make an affect on a left button that when you hover over it there is a smaller arrow appearing and the whole button expand into the left side of the screen, but for some reason it doesn't look as smooth as I want it too look and I can't find a way to make it that way, can someone help me? :)
PS:Rmain is the arrow always displayed on the button, Rside is the arrow that appearing when you hover over the button.
html:
<button class="right">
<span class="Rmain"></span>
<span class="Rside"></span>
</button>
css:
.left {
background-color: rgba(255, 255, 255, 0.863);
border: 4px solid rgb(60, 57, 238);
color: rgb(0, 0, 0);
padding: 145px 10px;
margin: 50px;
width: 55px;
text-align: right;
border-radius: 10%;
position: absolute;
transition: 0.6s;
}
.left:hover {
box-shadow: 5px 12px 16px 0 rgba(0, 0, 0, 0.4);
background-color: rgb(60, 57, 238);
color: rgb(255, 255, 255);
opacity: 75%;
cursor: pointer;
border-left-width: 95px;
transition: 0.6s;
}
.Lmain {
position: absolute;
height: 0px;
width: 0px;
top: 40%;
right: 86%;
font-size: 40px;
}
.Lmain::after {
content: '\290C';
}
.Lside {
position: absolute;
color: white;
height: 0px;
opacity: 0;
top: 40%;
right: 58%;
font-size: 39px;
transition: 0.4s;
}
.Lside::after {
content: '\2039';
}
.left:hover .Lside {
right: 72%;
transition: 1s;
opacity: 1;
}
button:focus {
outline: 0;
}
I'm not sure if this is what you're looking for, but it looks better this way:
add border-right-width:20px; into .left:hover section of css

How to add an opaque overlay to an image, that also has text on top of the image?

I'm trying to put an opaque layer above an image that also has responsive text on top of it. The opaque layer should be above the image, but below the text, and also not display upon hovering over the image.
My test page is here: https://www.gorgeous-geek.com/image-layer-test/
I tried to add a layer div, but can't find out how to do this to achieve the result I'm looking for.
Also, I don't manage to correctly right align the orange button with the right hand side of the image. It shows up in different places on Chrome and Safari.
Any help appreciated!
This is the code:
.containerbox {
position: relative;
color: white;
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 17.5%;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" style="border: 1px solid #ececec;" alt="Laptop" style="width:100%;">
<div class="top-left">Top Left</div>
<div class="bottom-right">Read more</div>
</div>
</div>
You could use the image filter as shown below. As for the position of the read more button I don't know the result you're looking for.
.containerbox {
position: relative;
}
.containerbox img {
border: 1px solid #ececec;
width: 100%;
filter: opacity(50%);
transition: filter .5s ease-out;
}
.containerbox:hover img {
filter: opacity(100%);
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 17.5%;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" alt="Laptop">
<div class="top-left">Top Left</div>
<div class="bottom-right">
Read more
</div>
</div>
Update
.containerbox {
position: relative;
}
.containerbox img {
border: 1px solid #ececec;
width: 100%;
}
.overlay {
position: absolute;
background: linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%));
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(59%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 0.65)));
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%);
z-index: 1;
height:100%;
top: 0;
left: 0;
width: 100%;
opacity: 100;
transition: opacity .5s ease-out;
}
.containerbox:hover .overlay {
opacity: 0;
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
z-index: 2;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 0;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
z-index: 2;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" alt="Laptop">
<div class="overlay"></div>
<div class="top-left">Top Left</div>
<div class="bottom-right">
Read more
</div>
</div>
You can utilize the z-index property to control the way your elements are layered:
The z-index property specifies the stack order of an element.
An element with greater stack order is always in front of an element with a lower stack order.
Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky).
Source
Below, I created an overlay using the :after psuedo element of .containerbox, and I gave that overlay a z-index: 1. Then, I gave the elements I want to display above my overlay a z-index: 2:
.containerbox {
position: relative;
color: white;
}
.containerbox:after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: white;
opacity: .5;
z-index: 1;
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
z-index: 2;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 17.5%;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
z-index: 2;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" style="border: 1px solid #ececec;" alt="Laptop" style="width:100%;">
<div class="top-left">Top Left</div>
<div class="bottom-right">Read more</div>
</div>

Half-circle, transparent cutout from bordered div with gradient background

I would like to accomplish the following graphic style with CSS:
I've been able to successfully replicate (approach) every single aspect of the intended design, except for the half-circle cutouts.
The closest I've been able to get is masking out the parts of the node body by setting a background-color for the cutout circles matching that of the backdrop, as well as inset shadows and border on the corresponding side.
After that, I added an extension towards the opposite direction, so that any shadow cast by the node is also effectively masked out. These are the results:
body {
font-family: "Segoe UI";
background-color: #eaeaea;
}
/* --- cutout --- */
.node-cutout-left {
position: absolute;
background-color: #eaeaea;
left: -1px;
width: 18px;
height: 36px;
border-top-right-radius: 50px;
border-bottom-right-radius: 50px;
border: 1px solid rgba(122, 167, 200, 0.7);
border-left: none;
box-shadow: -1px 1px 1px rgba(0,0,0,0.05) inset;
}
.node-cutout-left::after {
content: '';
display: block;
position: absolute;
left: -18px;
top: 0px;
height: 36px;
width: 18px;
background-color: #eaeaea;
}
/* --- end of cutout --- */
.node {
cursor: move;
position: absolute;
top: 12px;
left: 20px;
width: 160px;
box-shadow: 1px 1px 5px rgba(0,0,0,0.25);
border: 1px solid rgba(122, 167, 200, 0.7);
}
.node-header {
min-height: 20px;
padding: 6px 12px;
background-color: #489ddb;
color: #fff;
font-size: 12pt;
font-weight: 100;
box-shadow: 0px 0px 0px 1px #489ddb; /* overlay node-border */
}
.node-body {
position: relative;
min-height: 100px;
padding: 12px 24px;
background: #ffffff;
background: linear-gradient(170deg, #ffffff 0%,#e5e5e5 100%);
border: 1px solid rgba(255,255,255,0.5);
}
<div class="node" draggable="true" ondragstart="console.log(event);">
<div class="node-header">
<div class="node-title">Gain</div>
</div>
<div class="node-body">
<div class="node-cutout-left" style="top:20px;"></div>
<div class="node-cutout-left" style="top:70px;"></div>
</div>
</div>
However, I need transparent background in the masked out area. How could I accomplish this?
I've also prepared a JSFiddle (illustrating the problem) for those who'd wish to join this brainstorm, and whose help I would appreciate beyond measure.
Questions already on SO failed to solve my issue so far, as they use either the box-shadow of the element used as the cutout to fill the rendered area of the clipped element (which would cancel out the gradient background in my case)...
... or SVG clips, for which I -- for the life of it -- can't find a working example when applied to HTML elements with bordered style.
Ok, here you are. Probably it can be achieved in less code, but it's a start.
Only the gradient is a small issue..
body {
font-family: "Segoe UI";
background-color: #ccc;
}
* {
box-sizing: border-box;
}
.node {
cursor: move;
position: absolute;
top: 40px;
left: 60px;
width: 180px;
}
.node-header {
min-height: 20px;
padding: 6px 12px;
background-color: #489ddb;
color: #fff;
font-size: 12pt;
font-weight: 100;
}
.node-body {
position: relative;
min-height: 100px;
padding-left: 19px;
}
.node-content {
padding: 12px 24px;
background: #fff;
background: linear-gradient(170deg, #ffffff 0%, #e5e5e5 100%);
width: 100%;
border: 1px solid rgba(122, 167, 200, 0.7);
border-left: none;
border-top: none;
min-height: 145px;
}
.node-cutout {
overflow: hidden;
width: 19px;
position: absolute;
left: 0;
top: 0;
height:200px;
}
.node-square {
position: absolute;
border-left: 1px solid rgba(122, 167, 200, 0.7);
border-bottom: 1px solid rgba(122, 167, 200, 0.7);
width: 19px;
height: 18px;
z-index: 1;
background-color:#eaeaea;
}
.round {
padding: 18px;
position: relative;
overflow: hidden;
display: block;
width: 0px;
}
.round:before {
content: '';
position: absolute;
width: 35px;
height: 35px;
border: 1px solid rgba(122, 167, 200, 0.7);
border-radius: 100%;
box-shadow: 0 0 0 200px #eaeaea;
z-index: 1
}
.round:after {
background-color: rgba(122, 167, 200, 0.7);
content: '';
position: absolute;
left: 0;
width:1px;
z-index: 1;
height: 18px;
display: inline-block;
}
.round.top:after {
margin-top: -18px;
}
.round.top:before {
left: -18px;
}
.round.bottom:before {
left: -18px;
top: -18px;
}
<div class="node" draggable="true" ondragstart="console.log(event);">
<div class="node-header">
<div class="node-title">Gain</div>
</div>
<div class="node-body">
<div class="node-content">
</div>
<div class="node-cutout">
<div class="node-cutout-left" style="">
<span class="round top"></span>
<span class="round bottom"></span>
</div>
<div class="node-cutout-left" style="margin-top:-17px;">
<span class="round top"></span>
<span class="round bottom"></span>
</div>
<div class="node-square">
</div>
</div>
</div>
</div>
Please try this:
<div class="node" draggable="true" ondragstart="console.log(event);">
<div class="node-header">
<div class="node-title">Gain</div>
</div>
<div class="node-body">
<i class="fa fa-volume-up fa_custom"></i>
<div class="node-cutout-left" style="top:20px;"></div>
<div class="node-cutout-left" style="top:70px;"></div>
</div>
</div>
CSS:
body {
font-family: "Segoe UI";
}
.fa_custom{position: absolute;
left: -11px;
z-index: 1000000;
color: #fff;
top: 32px;}
.node {
cursor: move;
position: absolute;
top: 40px;
left: 60px;
width: 180px;
border: 1px solid rgba(122, 167, 200, 0.7);
box-shadow: 1px 1px 5px rgba(0,0,0,0.25);
}
.node-header {
min-height: 20px;
padding: 6px 12px;
background-color: #489ddb;
color: #fff;
font-size: 12pt;
font-weight: 100;
}
.node-body {
position: relative;
min-height: 100px;
padding: 12px 24px;
background: #ffffff;
}
.node-cutout-left {
position: absolute;
background-color: #eaeaea;
left: -1px;
width: 18px;
height: 36px;
border-top-right-radius: 50px;
border-bottom-right-radius: 50px;
border: 1px solid rgba(122, 167, 200, 0.7);
border-left: none;
box-shadow: -1px 1px 1px rgba(0,0,0,0.05) inset;
}
.node-cutout-left::after {
content: '';
display: block;
position: absolute;
left: -19px;
top: 3px;
height: 30px;
width: 33px;
border-radius: 64%;
background-color: #489DDB;
}
JSFiddle Link: https://jsfiddle.net/jdqht5ch/