I'm trying to create a double bordered tool tip with a triangle but I can't figure out how to do the outline part because there is no outline-right/left/top/bottom.
Here is what I have so far
body {
background-color: rgb(83, 110, 218);
}
.trigger {
margin-top: 150px;
position: relative;
width: 30px;
height: 30px;
background-color: #000;
}
.tooltip {
/* Misc */
text-align: center;
padding-top: 20px;
background-color: white;
position: absolute;
width: 300px;
height: 50px;
left: 70px;
top: -25px;
outline-color: white;
outline-width: 3px;
outline-style: solid;
border-color: rgb(83, 110, 218);
border-width: 3px;
border-style: solid;
}
.tooltip:after,
.tooltip:before {
right: 100%;
top: 50%;
border: solid transparent;
content: " ";
position: absolute;
pointer-events: none;
}
.tooltip:after {
border-color: rgba(136, 183, 213, 0);
border-right-color: white;
border-width: 20px;
margin-top: -20px;
}
.tooltip:before {
border-color: rgba(194, 225, 245, 0);
border-right-color: rgb(83, 110, 218);
border-width: 26px;
margin-top: -26px;
}
<div class="trigger">
<div class="tooltip">
Hello World
</div>
</div>
Or go here: Fiddle
Does anybody know how to accomplish this?
For a pure CSS alternate, you can use the below snippet. It basically uses a double for the border-style of the main rectangle (instead of outline) and a pseudo-element which is rotated by 45 degrees to produce the triangle. The triangle has a border which is the same color as the inner border of the main rectangle (or the body) and a box-shadow which is white in color to produce the double border effect. The pseudo-element is positioned appropriately to make it look as though it is a continuation of the border of the main rectangle.
Note: To modify the thickness of the border, the border-width of parent, border-width of the pseudo-element, the box-shadow on the pseudo-element and the positioning of the pseudo-element should be modified accordingly.
body {
background-color: rgb(83, 110, 218);
}
.trigger {
margin-top: 150px;
position: relative;
width: 30px;
height: 30px;
background-color: #000;
}
.tooltip {
/* Misc */
text-align: center;
padding-top: 20px;
background-color: white;
position: absolute;
width: 300px;
height: 50px;
left: 70px;
top: -25px;
border-color: rgb(83, 110, 218);
border-width: 6px;
border-style: double;
}
.tooltip:before {
left: -11.75px;
top: 35%;
height: 20px;
width: 20px;
border: 2.5px solid rgb(83, 110, 218);
box-shadow: -2px 2px 0px 0px white;
border-right: none;
border-top: none;
content: " ";
background: white;
position: absolute;
pointer-events: none;
transform: rotate(45deg);
}
<div class="trigger">
<div class="tooltip">
Hello World
</div>
</div>
I'd suggest you to use svg.
body {
background: rgb(83, 110, 218)
}
<svg width="300" height="60" viewBox="0 0 300 60">
<path d="M20 5h270v50h-270v-12.5l-10 -12.5l10 -12.5z" fill="white" />
<path d="M16 1h278v58h-278v-15l-11 -14 l11,-14z" fill="none" stroke-width="2.5" stroke="white" />
<text x="150" y="35" text-anchor="middle">Hello World</text>
</svg>
Related
I am using Tooltip to display text when hover over exclamation symbol as shown in the video. Problem is I see orange border appears when I click on the component.
How can I get rid of that border and show tooltip only when click on symbol?
Live Demo - https://screenrec.com/share/yj3OQE2hxw
Code
.tooltiptext {
width: 275px;
height: 141px;
background: -colors.$white;
border: 1px solid rgb(220, 220, 220);
border-radius: 3px;
text-align: start;
color: -colors.$black;
font-weight: normal;
font-family: -fonts.$-font-family-regular;
letter-spacing: 0px;
line-height: 22px;
box-shadow: 0px 4px 6px 0px rgba(34, 34, 34, 0.1);
margin-left: -150px;
bottom: 125%;
visibility: hidden;
position: absolute;
padding: 10px;
}
.tooltip .tooltiptext:after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -12px;
border-width: 7px;
border-style: solid;
border-color: -colors.$white transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
.toolClass {
display: inline-block;
height: 18px;
width: 18px;
transform: translateY(3px);
svg {
fill: #cdcdcd;
}
}
<div class="btn-text">
{{ Data 1 }}
<div class="toolClass tooltip" tooltip tooltipPlacement="top">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 16 16">
<path d="M9,4c2.8,0,5,2.2,5,5s-2.2,5-5,5s-5-2.2-5-5S6.2,4,9,4 M9,2C5.1,2,2,5.1,2,9s3.1,7,7,7s7-3.1,7-7 c0-1.9-0.7-3.6-2.1-4.9S10.9,2,9,2z M8,8.5v4.4h2V8.5H8z M8,5.2v2h2v-2H8z"/>
</svg>
<span class="tooltiptext">{{This product is related to Amazon}}</span>
</div>
</div>
How can I add a right facing triangle to the end of a div? I want the content/size of the div to be the same, just with a right facing triangle on the right side of the div. Thanks.
For right arrow in the middle of the content box
.arrow_box {
position: relative;
background: #88b7d5;
border: 2px solid #c2e1f5;
height: 40px;
width: 80px;
}
.arrow_box:after,
.arrow_box:before {
left: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(136, 183, 213, 0);
border-left-color: #88b7d5;
border-width: 10px;
margin-top: -10px;
}
.arrow_box:before {
border-color: rgba(194, 225, 245, 0);
border-left-color: #c2e1f5;
border-width: 13px;
margin-top: -13px;
}
<div class="arrow_box"></div>
I have a dialogue box or a arrow box which should be set to max height of 60%, and all the content inside the box overflows via scroll, this is the markup:
<div class="cart">
hello world
</div>
and here is the css to make a arrow-head on top:
.cart {
position: fixed;
background: #ffffff;
opacity: 1;
box-shadow: 1px 1px 10px;
border-radius: 5px;
margin-left: 74.8%;
width: 300px;
top: 70px;
padding: 13px;
z-index: 20;
text-align: center;
display: none;
max-height: 60%;
overflow: auto;
}
.cart:after, .cart:before {
top: -20px;
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.cart:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #ffffff;
border-width: 10px;
margin-left: -10px;
}
.cart:before {
border-color: rgba(12, 143, 176, 0);
border-bottom-color: #999;
border-width: 11px;
margin-left: -11px;
}
if I remove the "overflow" property the arrow head shows up, but when I use it, which I have to It disappears, I want both, an arrow head and scrollable div, but I think the arrowhead just gets inside the scroll. is there any solution for this?
Thanks for the help
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/
How do you create the arrow that appears when you hover over "Reviews" on this site?
http://mac.appstorm.net/category/reviews/
I want to create this via css but am not sure how to do so. Also what is the correct "term" for that?
Thanks!
You can see an example at Simple Stock Search if you register and hover over one of the menu options.
The CSS for such an arrow is:
.reviews:after
{
content: "";
z-index: 9999;
position: absolute;
bottom: -10px;
left: 50%;
margin-left: -10px;
border-top: 10px solid red;
border-right: 10px solid transparent;
border-left: 10px solid transparent;
}
Visit this JSFiddle for a demo.
from cssarrowplease.com
demo
HTML
<span class="arrow_box">test</span>
CSS
.arrow_box:hover {
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
width: 100px;
display:inline-block;
height: 25px;
}
.arrow_box:hover:after, .arrow_box:hover:before {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:hover:after {
border-color: rgba(136, 183, 213, 0);
border-top-color: #88b7d5;
border-width: 5px;
margin-left: -5px;
}
.arrow_box:hover:before {
border-color: rgba(194, 225, 245, 0);
border-top-color: #c2e1f5;
border-width: 11px;
margin-left: -11px;
}