Can anyone give me any ideas how to achieve a html input that has pointed edge on it.
Something like this:
from:
________
|________|
To:
_______
<_______>
Below are my contributions to adaam's work. I have the right arrow now fitting on the right side of the input box and aligned them a bit better.
HTML:
<div class="sharp"><input type="text" value="test"/></div>
CSS:
input[type="text"] {
width: 140px;
}
div.sharp {
height:30px;
width:133px;
position:relative;
margin:0 30px;
}
div.sharp:before {
content: "";
position: absolute;
top: 1px;
left: -20px;
width: 0;
height: 0;
border-style: solid;
border-width: 10px 20px 10px 0;
border-color: transparent #000 transparent transparent;
line-height: 0px;
_border-color: #000000 #000 #000000 #000000;
_filter: progid:DXImageTransform.Microsoft.Chroma(color='#000000');
}
div.sharp:after {
content:"";
position: absolute;
top: 1px;
right: -30px;
width: 0;
height: 0;
border-style: solid;
border-width: 10px 0 10px 20px;
border-color: transparent transparent transparent #000;
line-height: 0px;
_border-color: #000000 #000 #000000 #000000;
_filter: progid:DXImageTransform.Microsoft.Chroma(color='#000000');
}
http://jsfiddle.net/P89WD/9/
You could try something like this. Put a div on either side of the input box and form it into a triangle.
I have achieved it through multiple images in input
input.yourClassname {
border-bottom: 1px solid #7e8ba4;
background-image: url(../css/images/inputBorderLeft.png), url(../css/images/inputBorderLeft.png);
background-repeat: no-repeat;
background-position: bottom left, bottom right;
}
Related
Im looking for css code for below shape, i have tried using border radius but have to work with different div's for top border and left curve.
Im looking for css which draws complete shape below. Any help ?
.Curve{
top: 25px;
left: 25px;
width: 50px;
border: solid 1px #4C5D65;
height: 86px;
content: " ";
padding: 0px;
position: absolute;
transform: rotate(271deg);
border-color: transparent transparent #4C5D65 transparent;
border-radius: 0 0 51px 99%/44px;
}
<span class="Curve"> </span>
Here is what i have tried
https://jsfiddle.net/sonymax46/wdaLomnf/3/
Here is an idea with one element. Simply adjust the gradient until you get what you want.
.curve {
width:100px;
height:50px;
border-top:2px solid;
background:
radial-gradient(100% 57% at left,transparent calc(100% - 2px),#000,transparent 100%)
left/15px 100% no-repeat;
}
<div class="curve"></div>
Another idea:
.curve {
width:100px;
height:50px;
border-top:2px solid;
position:relative;
overflow:hidden;
}
.curve:before {
content:"";
position:absolute;
width:80px;
height:80px;
border-radius:50%;
top:calc(50% - 40px);
right:calc(100% - 12px);
border:2px solid;
box-sizing:border-box;
}
<div class="curve"></div>
Maybe change
border-color: transparent transparent #4C5D65 transparent; to
border-color: #4C5D65 transparent #4C5D65 transparent;
or add an element above, make the margins of both equal to zero, and then make the bottom border the same colour.
Hope this help you.
.Curve {
top: 25px;
left: 25px;
width: 50px;
border: solid 1px #4C5D65;
height: 86px;
content: " ";
padding: 0px;
position: absolute;
transform: rotate(271deg);
border-color: transparent transparent #4C5D65 transparent;
border-radius: 0 0 51px 99%/44px;
}
span.Curve:after {
position: absolute;
content: '';
height: 100%;
width: 100%;
border-right: 1px solid #21262D;
top: 92%;
left: -6px;
/* background: rebeccapurple; */
}
<span class="Curve"></span>
I'm trying to create a curved triangle to be put next to a 'chat message box'.
See this example:
As you can see in between the 'E' and the actual message box there is a little 'triangle' but its shape isnt made of a straigt line, instead it's a little bit curved.
On top of that, I would like to add a box-shadow to my triangle.
Here's the code that I have tried:
width: 0px;
height: 0px;
border-top: 32px solid transparent;
border-bottom: 0px solid transparent;
border-right: 22px solid white;
position: absolute;
left: -10px;
bottom: 0;
box-shadow: 0 2px 6px rgba(0,0,0,.9);
And it gives me this result: (I have purposefully added a super dark box-shadow so that it easier to understand my problem.)
So, to recap, what I'd like to achieve:
A triangle that has one of its line curved as in the very first picture
a box shadow around that triangle, that 'fits' with the other box shadow of the other element.
Thanks !
Based on a previous answer, you can add a drop-shadow filter to a shape created using radial-gradient for the curve:
.userMsgBottom {
position: relative;
color:#fff;
max-width: 250px;
background-color: #2e7384;
margin: 30px 50px;
padding: 10px;
border-radius: 6px;
filter:drop-shadow(0 0 5px #000);
}
.userMsgBottom:after {
content: "";
position: absolute;
bottom: 0px;
right: -23px;
width: 30px;
height: 25px;
background: radial-gradient(circle at top right, transparent 60%, #2e7384 62%);
}
.left.userMsgBottom:after {
content: "";
position: absolute;
bottom: 0px;
left: -23px;
width: 30px;
height: 25px;
background: radial-gradient(circle at top left, transparent 60%, #2e7384 62%);
}
<div class="userMsgBottom">
Some text here Some text here Some text here
</div>
<div class="userMsgBottom left">
Some text here Some text here Some text here
</div>
Safari doesn't support the syntax with at, here is another syntax for better support:
.userMsgBottom {
position: relative;
color:#fff;
max-width: 250px;
background-color: #2e7384;
margin: 30px 50px;
padding: 10px;
border-radius: 6px;
filter:drop-shadow(0 0 5px #000);
}
.userMsgBottom:after {
content: "";
position: absolute;
bottom: 0px;
right: -23px;
width: 30px;
height: 25px;
background:
radial-gradient(circle, transparent 60%, #2e7384 62%) bottom left/200% 200%;
}
.left.userMsgBottom:after {
content: "";
position: absolute;
bottom: 0px;
left: -23px;
width: 30px;
height: 25px;
background:
radial-gradient(circle, transparent 60%, #2e7384 62%) bottom right/200% 200%;
}
<div class="userMsgBottom">
Some text here Some text here Some text here
</div>
<div class="userMsgBottom left">
Some text here Some text here Some text here
</div>
I have created a ribbon with css only. Now i want to make a 1px grey border around it. But the left and right side of the image are created already with a css border. is this possible to do that?
The image should look like this (you see the 1 px grey border):
This is the html and css i use to create the image:
.yellow-ribbon-top-left {
width: 0;
height: 0;
border-style: solid;
border-width: 30px 30px 0 0;
border-color: #eedc08 transparent transparent transparent;
float: left;
}
.yellow-ribbon-mid {
width: 120px;
height: 30px;
float: left;
background-color: #eedc08;
}
.yellow-ribbon-bottom-right {
width: 0;
height: 0;
border-style: solid;
border-width: 0 0 30px 30px;
float: left;
border-color: transparent transparent #eedc08 transparent;
}
<div class="yellow-ribbon-bottom-right"></div>
<div class="yellow-ribbon-mid"></div>
<div class="yellow-ribbon-top-left"></div>
You can simplify you code by using skew transformation then you can easily adjust border:
.yellow-ribbon {
width: 120px;
height: 30px;
margin:20px;
background-color: #eedc08;
border:1px solid #000;
transform:skew(-30deg);
}
<div class="yellow-ribbon">
</div>
By the way if you want to keep your actual code you can rely on pseudo-element like this (but i don't recommend this solution as it makes the code even more complicated and we have above a simple one):
.yellow-ribbon-top-left {
width: 0;
height: 0;
border-style: solid;
border-width: 30px 30px 0 0;
border-color: #eedc08 transparent transparent transparent;
float: left;
position: relative;
top: 1px;
}
/* create border around the left part */
.yellow-ribbon-top-left:before {
content: "";
position: absolute;
border-style: solid;
border-width: 32px 32px 0 0;
border-color: #000 transparent transparent transparent;
bottom: -1px;
z-index:-1
}
/* */
.yellow-ribbon-mid {
width: 120px;
height: 30px;
float: left;
background-color: #eedc08;
border-top: 1px solid;
border-bottom: 1px solid;
position: relative;
}
.yellow-ribbon-bottom-right {
width: 0;
height: 0;
border-style: solid;
border-width: 0 0 30px 30px;
float: left;
border-color: transparent transparent #eedc08 transparent;
position:relative;
top:1px;
}
/* create border around the right part */
.yellow-ribbon-bottom-right:before {
content: "";
position: absolute;
border-style: solid;
border-width: 0 0 32px 32px;
border-color: transparent transparent #000 transparent;
top: -1px;
right: 0;
z-index:-1
}
/* */
<div class="yellow-ribbon-bottom-right"></div>
<div class="yellow-ribbon-mid"></div>
<div class="yellow-ribbon-top-left"></div>
So assuming I have the below triangle. Without adding any html or tags how could I go about positioning the text into the center of the triangle?
Fiddle: http://jsfiddle.net/3LXaD/
You will notice the white text in the top right corner of the triangle. I understand a triangle is a large border around the shape. Is this even possible?
CSS
div:nth-of-type(1) {
width: 0;
height: 0;
border-style: solid;
border-width: 0 150px 130px 150px;
border-color: transparent transparent #d30000 transparent;
line-height: 0px;
_border-color: #000000 #000000 #d30000 #000000;
_filter: progid:DXImageTransform.Microsoft.Chroma(color='#000000');
}
div {
font-size: 16px;
color: #FFFFFF;
text-align: center;
}
HTML
<div>This is a triangle</div>
Without extra markup try this:
div:nth-of-type(1):before {
content: '';
width: 0;
height: 0;
border-style: solid;
border-width: 0 150px 130px 150px;
border-color: transparent transparent #d30000 transparent;
line-height: 0px;
_border-color: #000000 #000000 #d30000 #000000;
_filter: progid:DXImageTransform.Microsoft.Chroma(color='#000000');
position: absolute;
top: 0;
z-index: -1;
left: 50%;
margin-left: -150px;
}
div {
font-size: 16px;
color: #ffffff;
text-align: center;
line-height: 130px;
position: relative;
}
Here is an example.
Ciao
Ralf
Wrap the text in the span and position it absolutely:
JSfiddle
span{
position: absolute;
top: 80px;
left: 33%;
}
<div><span>This is a triangle</span></div>
Here would be the solution if you were to use a pseuedo element. (not best practice)
div:after{
content: 'This is a triangle';
color: white;
position: absolute;
top: 80px;
left: 33%;
}
I'm using bootstrap, trying to make a div have a CSS triangle before it.
http://jsfiddle.net/B2XvZ/11/
Here is my non-working code:
.d:before {
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 15px 10px 0;
border-color: transparent #dd4397 transparent transparent;
}
The way I'd like it to look is for there to be a pink left-pointing triangle right before the text "this", with no gap between it and the div. I've tried to do this by floating the elements also, with no success.
You need to specify the content property.
For positioning, add position:relative to the parent, and then absolutely position the arrow -15px to the left.
jsFiddle example
.d {
position:relative;
}
.d:before {
content:"\A";
border-style: solid;
border-width: 10px 15px 10px 0;
border-color: transparent #dd4397 transparent transparent;
position: absolute;
left: -15px;
}
You need content property and some other
.d:before {
content: '';
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 15px 10px 0;
border-color: transparent #dd4397 transparent transparent;
display: inline-block;
vertical-align: middle;
margin-right: 5px;
}
a:after {
content: '';
width: 0px;
height: 0px;
border-style: solid;
border-width: 15px 15px 0px 15px;
border-color: #fff transparent transparent transparent;
display: inline-block;
vertical-align: middle;
position: absolute;
bottom: -13px;
left: 0;
right: 0;
margin: 0 auto;
}
You can use UTF-8 Geometric Shapes.
a:before {
content: '\25B2'
}
in your HTML need a meta charset:
<html>
<head>
<meta charset="utf-8" />
...
</head>
</html>
Geometric shapes list:
https://www.w3schools.com/charsets/ref_utf_geometric.asp