Hi I am trying to make a translucent speech bubble with a border. To make the triangle I am using a ::before element for large triangle and an ::after for a smaller one that sits on top, so it looks like it has a border. But since I want it translucent, the ::before element can be seen and ruins it. Please help me to fix this
.bubble {
max-width: 75%;
min-width: 200px;
padding: 8px 12px 0 12px;
position: relative;
border-radius: 4px;
text-align: left;
margin-left: auto;
background-color: rgba(255, 0, 0, 0.3);
border: 1px solid black;
border-top-right-radius: 0;
margin-right: 16px;
}
.bubble::before, .bubble::after {
position: absolute;
width: 0;
height: 0;
top: 0;
content: '';
border-style: solid;
right: 0;
transform: translateX( 100% );
}
.bubble::before {
border-color: black transparent transparent transparent;
border-width: 18px 18px 0 0;
top: -1px;
}
.bubble::after {
border-color: rgba(255, 0, 0, 0.3) transparent transparent transparent;
border-width: 16px 16px 0 0;
}
<div class="bubble">
<p>
Hello
</p>
</div>
A skew transformation can help you here:
.bubble {
max-width: 75%;
min-width: 200px;
padding: 8px 12px 0 12px;
position: relative;
border-radius: 0 0 4px 4px;
margin-top:40px;
border: 1px solid black;
border-top:0;
margin-right: 16px;
}
.bubble::before,
.bubble::after{
content: '';
position: absolute;
width: 70%;
height: 20px;
top: -21px;
border:1px solid;
}
.bubble::before {
right:-1px;
border:1px solid;
border-width:1px 1px 0 0;
transform-origin:bottom;
transform:skew(-45deg);
}
.bubble::after{
left:-1px;
border-width:1px 0 0 1px;
border-radius:4px 0 0 0;
}
p {
margin-top:0;
}
<div class="bubble">
<p>
Hello
</p>
</div>
Try a same color without transparency using color-picker . It can solve your problem .
See in below snippet
.bubble {
max-width: 75%;
min-width: 200px;
padding: 8px 12px 0 12px;
position: relative;
border-radius: 4px;
text-align: left;
margin-left: auto;
background-color: rgba(255, 0, 0, 0.3);
border: 1px solid black;
border-top-right-radius: 0;
margin-right: 16px;
}
.bubble::before, .bubble::after {
position: absolute;
width: 0;
height: 0;
top: 0;
content: '';
border-style: solid;
right: 0;
transform: translateX( 100% );
}
.bubble::before {
border-color: black transparent transparent transparent;
border-width: 18px 18px 0 0;
top: -1px;
}
.bubble::after {
border-color: rgb(255, 178, 178) transparent transparent transparent;
border-width: 16px 16px 0 0;
}
<div class="bubble">
<p>
Hello
</p>
</div>
I've created an svg for you. Would this help?
<svg
id="ff27feca-6648-4bac-87a3-a2646769617b"
data-name="Layer 1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 694 178"
>
<defs>
<style>
.a7bae820-8942-4935-b994-ad6a9d32b3d2 {
fill: none;
stroke: #000;
stroke-miterlimit: 10;
stroke-width: 10px;
}
</style>
</defs>
<path
class="a7bae820-8942-4935-b994-ad6a9d32b3d2"
d="M567.37,164H44.63A29.64,29.64,0,0,1,15,134.37V45.63A29.64,29.64,0,0,1,44.63,16H667L597,67v67.37A29.64,29.64,0,0,1,567.37,164Z"
/>
</svg>
Related
In this card, I have given an image tag. When I run the code half of the image gets hidden. My exception is that the image should overwrite the card like this:
.
So please let me know how to achieve this.
Here is my code:
.section6-card1-diagonal {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-color: transparent;
width: 246px;
height: 406px;
border-color: lightgrey;
margin-left: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
}
<div class="card section6-card1-diagonal">
<h5>Dell Inspiron Heavy metallic Display</h5>
<img class="section4-image" src="https://i5.walmartimages.com/asr/726f43a4-2dbb-4340-adc1-ce798580ba23_1.c5ced9469e3036a57d81678e9ebd2f1d.jpeg" />
<div class="cards1">
</div>
</div>
Here is a simple solution .
Just give negative z-index to the .cards1
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
z-index:-1;
}
That will bring the div behind the image , Because the Image will have more priority in simple words
play width .section4-image class for better styling
.section6-card1-diagonal {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-color: transparent;
width: 246px;
height: 406px;
border-color: lightgrey;
margin-left: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
}
.section4-image {
height: 55vh;
background-color: "red";
width: 52vh;
margin-left: 10%;
margin-top: 0%;
}
<div class="card section6-card1-diagonal">
<h5>Dell Inspiron Heavy metallic Display</h5>
<img class="section4-image" src="https://i5.walmartimages.com/asr/726f43a4-2dbb-4340-adc1-ce798580ba23_1.c5ced9469e3036a57d81678e9ebd2f1d.jpeg" />
<div class="cards1">
</div>
</div>
Firstly: you need to upload transparent image (PNG) image of desktop.
Secondly: you need to upload small resolution image.
Currently you uploaded high resolution image which is 1500x1500
Now you need to add below css to show you image and also make it transparent.
.section4-image {
width:100%;
}
After make transparent image you need to add z-index css on image for show up on the shape.
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
z-index: -1;
}
.section4-image {
z-index: 1;
}
`
.section6-card1-diagonal {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-color: transparent;
width: 246px;
height: 406px;
border-color: lightgrey;
margin-left: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
}
.section4-image {
width:100%;
}
<div class="card section6-card1-diagonal">
<h5>Dell Inspiron Heavy metallic Display</h5>
<img class="section4-image" src="https://i5.walmartimages.com/asr/726f43a4-2dbb-4340-adc1-ce798580ba23_1.c5ced9469e3036a57d81678e9ebd2f1d.jpeg" />
<div class="cards1">
</div>
</div>
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent ;
transform-origin: 0 0;
transform: rotate(135deg);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .5);
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
Can you please replace ".triangle::after" with this code and check whether it solves you problem or not?
.triangle::after {
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent;
transform-origin: 0 0;
transform: rotate(135deg);
background: #fff;
box-shadow: -2px 2px 2px 1px rgb(233, 233, 233);
}
Just add z-index: -1; to the pseudo element to move it behind the main element:
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent ;
transform-origin: 0 0;
transform: rotate(135deg);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .5);
z-index: -1;
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
It may be help and also looks good
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 17px;
right: 1%;
box-sizing: border-box;
border: 0.75em solid;
border-color: #fff;
transform-origin: 0 0;
transform: rotate(-133deg);
box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.3);
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
Same method use here.
Z-index: -1 is safe bro
This is what I want to achieve:
I'm looking to "cut" the lower left corner of the content in the code below
(similar to if you had folded the corner of a page down)
I'd like to know if there is any adjustments I could do to the CSS below to achieve this.
.model-properties {
padding: 0.8em 3em;
position: absolute;
top: 0px;
right: 0px;
width: 20%;
min-width: 15%;
z-index: 2;
display: none;
color: #c6d2db;
font-size: 13px;
background: linear-gradient(180deg, #182229, #182229, #293741, #293741);
max-height: 700px;
overflow: auto;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<div id="model-properties-container" class="model-properties">
.model-properties:before,
.model-properties:after
{
bottom: 0;
left: 0;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.model-properties:after {
border-color: #88b7d5;
border-left-color: white;
border-bottom-color: white;
border-width: 30px;
}
https://jsfiddle.net/e46xvp3x/3/
I am trying to create right arrow with gray border with css. but I think the arrow is over lapping the left rectangle. some finishing touch is required here:
.arrow_box {
position: relative;
background: #fff;
border: 2px solid #aaa;
width: 300px;
padding: 8px 20px 8px 40px;
}
.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(255, 255, 255, 0);
border-left-color: #fff;
border-width: 17px;
margin-top: -17px;
}
.arrow_box:before {
border-color: rgba(170, 170, 170, 0);
border-left-color: #aaa;
border-width: 19px;
margin-top: -19px;
}
<div class="arrow_box">Consumer Customer
</div>
You can add border on specific sides except right:
.arrow_box {
position: relative;
background: #fff;
border-left: 2px solid #aaa;
border-top: 2px solid #aaa;
border-bottom: 2px solid #aaa;
width: 300px;
padding: 8px 20px 8px 40px;
box-sizing: border-box;
}
https://jsfiddle.net/2ca4aucm/1/
This is what i have got so far
After after checking out tutorial
I want know how curved effect is generated on divs the only question that i found near to what i was looking for was At here at stackoverlow but that too dint help
How folded edge effect is created on as in the above picture
Css
#MenuShape{
height:50px;
background-color:orange;
width:200px;
position:relative;
text-align:center;
left:100px;
}
#MenuShape:after{
content:"";
position: absolute;
width: 0;
height: 0;
left:200px;
border-top: 50px solid transparent;
border-left: 100px solid orange;
border-bottom: 0px solid transparent;
}
#MenuShape:before{
content:"";
position: absolute;
width: 0;
height: -50;
left:-100px;
border-top: 50px solid transparent;
border-right: 100px solid orange;
border-bottom: 0px solid transparent;
}
HTML
<div id="MenuShape" >
sachin
</div>
https://css-tricks.com/ this the site on inspecting it i found its span wrapped
anchor tag along with svg tag
<a href="/" class="home">
<svg viewBox="0 0 100 25" class="shape-tab">
<use xlink:href="#shape-tab"></use>
</svg>
<span>Blog</span></a>
Click here to see the unexpected behaviour it works fine in codepen
Here is a final demo (archived) on the folded corners:
and the following code is how you can create them:
.note {
position: relative;
width: 30%;
padding: 1em 1.5em;
margin: 2em auto;
color: #fff;
background: #97C02F;
overflow: hidden;
}
.note:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 16px 16px 0;
border-style: solid;
border-color: #fff #fff #658E15 #658E15;
background: #658E15;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
/* Firefox 3.0 damage limitation */
display: block;
width: 0;
}
.note.rounded {
-moz-border-radius: 5px 0 5px 5px;
border-radius: 5px 0 5px 5px;
}
.note.rounded:before {
border-width: 8px;
border-color: #fff #fff transparent transparent;
-moz-border-radius: 0 0 0 5px;
border-radius: 0 0 0 5px;
}
<div class="note"></div>
To create a curved wave effect you can use this code:
#wave {
position: relative;
height: 70px;
width: 600px;
background: #e0efe3;
}
#wave:before {
content: "";
display: block;
position: absolute;
border-radius: 100% 50%;
width: 340px;
height: 80px;
background-color: white;
right: -5px;
top: 40px;
}
#wave:after {
content: "";
display: block;
position: absolute;
border-radius: 100% 50%;
width: 300px;
height: 70px;
background-color: #e0efe3;
left: 0;
top: 27px;
}
<div id="wave"></div>
To achieve the curve you’ll need to inverse where it starts. Follow the same demo, just reverse your values.
See a live demonstration (archived) of how border radius can create the shapes and effects you want and adjust each corner to see it in action.