How to outline arrow in css - html

I've managed to set an outline but it's not going around the arrow but around the whole box. Is there a fix for this?
.arrows {
position: absolute;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
}
.arrow {
border: solid #49fb35;
border-width: 0 10px 10px 0;
display: inline-block;
padding: 25px;
outline: solid black;
outline-width: 3px;
}
.down {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<div class="arrows">
<i class="arrow down"></i>
</div>

The outline will make an outline to the whole box, if you want the outline to surround only the border, it would be tricky, this might be what you're looking for if you want CSS only solution.
.arrows {
position: absolute;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
}
.arrow {
border: solid #49fb35;
border-width: 0 10px 10px 0;
display: inline-block;
padding: 25px;
box-shadow: 3px 3px 0px 2px black, inset -3px -3px 0px 2px black
}
.arrow:before {
content: '';
width: 3px;
position: absolute;
left: 0;
bottom: -15px;
z-index: 100;
background: #000;
height: 16px;
}
.arrow:after {
content: '';
width: 16px;
position: absolute;
right: -15px;
top: 0;
z-index: 100;
background: #000;
height: 3px;
}
.down {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<div class="arrows">
<i class="arrow down"></i>
</div>

I am not sure if this is quite what you are looking for but might be useful starting point.
.arrows {
position: absolute;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
}
.arrow {
border: solid #49fb35;
border-width: 0 10px 10px 0;
display: inline-block;
padding: 25px;
box-shadow: 1px 1px 1px #000;
}
.down {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<div class="arrows">
<i class="arrow down"></i>
</div>

you can you ::before & ::after css to achieve this.
.arrows {
position: absolute;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
}
.arrow {
border-width: 0 10px 10px 0;
display: inline-block;
padding: 25px;
position: relative;
}
.arrow::after {
content: '';
width: 10px;
height: 100%;
background-color: #49fb35;
position: absolute;
left:0;
}
.arrow::before {
content: '';
width: 100%;
height: 10px;
background-color: #49fb35;
position: absolute;
left: 0;
}
.arrow::after,
.arrow::before {
box-shadow: 0px 0px 1px 1px black;
}
.down {
transform: rotate(225deg);
-webkit-transform: rotate(225deg);
}
<div class="arrows">
<i class="arrow down"></i>
</div>

Related

CSS pseudo element is not working as expected

I created a new style to show errors or any message.
input{
min-width:350px;
padding:10px;
}
.paswd_info_wrap.quick_note_error {
background: #f77777;
color: white;
position: relative;
margin-top: 0;
border-left: none;
font-size: 0.8em;
padding: 10px 20px;
margin-top:10px;
max-width:350px;
font-size:1.2em
}
.paswd_info_wrap {
padding: 10px;
text-align: center;
background: #efefef;
}
.paswd_info_wrap.quick_note_error:before {
content: '';
position: absolute;
border-right: 10px solid #ff000000;
border-left: 10px solid #ffffff00;
border-top: 10px solid #f77777;
left: calc(50% - 10px);
top: -10px;
transform: rotate( 180deg);
z-index: 10;
filter: drop-shadow(0px 0px 1px red);
}
.paswd_info_wrap.quick_note_error::after {
right: 0;
bottom: -10px;
transform: rotate(0deg);
top: auto;
left: calc(50% + 40px);
}
.quick_note_error::after {
content: '';
position: absolute;
border-right: 10px solid #ff000000;
border-left: 10px solid #ffffff00;
border-top: 10px solid #f77777;
left: 0px;
top: -10px;
transform: rotate( 180deg);
z-index: 10;
filter: drop-shadow(0px 0px 1px red);
}
<input type="text" placeholder="write password">
<div class="paswd_info_wrap quick_note_error">
<div class="paswd_err">Password is not given correct.</div>
</div>
I want to add text Error in bottom right as given below in an image.
I have tried to find solution by replacing content:'' with content: 'Error' (in CSS) but it is not working as expected.
IGNORE THIS -
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
I have tried a combo of clip-path and giving explicit height to the ::after pseudo element with minimal padding,text-align,box-shadow changes and not relying on border,drop-shadow. The following should work for you :-
input{
min-width:350px;
padding:10px;
}
.paswd_info_wrap.quick_note_error {
background: #f77777;
color: white;
position: relative;
margin-top: 0;
border-left: none;
font-size: 0.8em;
padding: 10px 20px;
margin-top:10px;
max-width:350px;
font-size:1.2em
}
.paswd_info_wrap {
padding: 10px;
text-align: center;
background: #efefef;
}
.paswd_info_wrap.quick_note_error:before {
content: '';
position: absolute;
border-right: 10px solid #ff000000;
border-left: 10px solid #ffffff00;
border-top: 10px solid #f77777;
left: calc(50% - 10px);
top: -10px;
transform: rotate( 180deg);
z-index: 10;
filter: drop-shadow(0px 0px 1px red);
}
.paswd_info_wrap.quick_note_error::after {
right: 0;
bottom: -10px;
transform: rotate(0deg);
top: 100%;
left: calc(50% + 40px);
}
.quick_note_error::after {
content: 'Error';
position: absolute;
left: 0px;
top: -10px;
padding-right:5%;
padding-bottom:2px;
text-align:right;
height:10px;
clip-path: polygon(9% 100%, 0 0, 100% 0, 91% 100%);
background:#f77777;
font-size:10px;
transform: rotate( 180deg);
box-shadow: inset 1px 1px 2px #f34c4c;
z-index: 10;
}
<input type="text" placeholder="write password">
<div class="paswd_info_wrap quick_note_error">
<div class="paswd_err">Password is not given correct.</div>
</div>
You can experiment with clip path's here as well for more precision - https://bennettfeely.com/clippy/
I just add another pseudo-element to display the text.
input{
min-width:350px;
padding:10px;
}
.paswd_info_wrap.quick_note_error {
background: #f77777;
color: white;
position: relative;
margin-top: 0;
border-left: none;
font-size: 0.8em;
padding: 10px 20px;
margin-top:10px;
max-width:350px;
font-size:1.2em
}
.paswd_info_wrap {
padding: 10px;
text-align: center;
background: #efefef;
}
.paswd_info_wrap.quick_note_error:before {
content: '';
position: absolute;
border-right: 10px solid #ff000000;
border-left: 10px solid #ffffff00;
border-top: 10px solid #f77777;
left: calc(50% - 10px);
top: -10px;
transform: rotate( 180deg);
z-index: 10;
filter: drop-shadow(0px 0px 1px red);
}
.paswd_info_wrap.quick_note_error::after {
right: 0;
bottom: -10px;
transform: rotate(0deg);
top: auto;
left: calc(50% + 40px);
}
.quick_note_error::after {
content: '';
position: absolute;
border-right: 10px solid #ff000000;
border-left: 10px solid #ffffff00;
border-top: 10px solid #f77777;
left: 0px;
top: -10px;
transform: rotate( 180deg);
z-index: 10;
filter: drop-shadow(0px 0px 1px red);
}
.paswd_err::after {
content: 'Error';
display: inline-block;
position: relative;
top: 24px;
right: 0;
width: 100px;
background: none;
z-index: 99;
font-size: 12px;
filter: drop-shadow(0px 0px 1px red);
}
<input type="text" placeholder="write password">
<div class="paswd_info_wrap quick_note_error">
<div class="paswd_err">Password is not given correct.</div>
</div>

Muller Lyer in Html

I'm trying to make a version of the Muller-Lyer illusion in HTML (no image files, because I want to make the line length variable).
Here's what I have so far; it's got the right elements but isn't working correctly. What's the best approach?
.arrow {
border: solid black;
border-width: 0 4px 4px 0;
display: inline-block;
padding: 40px;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.left {
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.line-container {
display: flex;
width: 100%;
margin: 20px auto;
align-items: center;
}
.line {
flex-grow: 1;
height: 2px;
background: black;
position: relative;
}
.line.arrow-right:after {
position: absolute;
content: '';
bottom: -10px;
right: 0;
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid transparent;
}
.line.arrow-left:after {
position: absolute;
content: '';
top: -10px;
left: 0;
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid transparent;
}
label {
margin: 0 15px;
}
<i class="arrow right"></i><div class="line-container"><span class="line arrow-left"></span><span class="line arrow-right"></span>
</div><i class="arrow left"></i>
I used your base cde and tried to simplify a bit.
Have a look at this codepen. Is it what you are looking for?
The "weakness" of using rotated borders is that the arrows are longer than the container div, that's the reason why I added some margin.
The best solution is probably to use SVG lines.
.line-container {
margin: 80px;
width: 400px;
height: 100px;
position: relative;
}
.arrow {
position: absolute;
border: solid black;
border-width: 0 8px 8px 0;
height: 100px;
width: 100px;
}
.right.out {
right: 16px;
}
.left.out {
left: 16px;
}
.right.in {
left: -120px;
}
.left.in {
right: -120px;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.left {
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.line {
width: 100%;
border-top: 8px solid black;
position: absolute;
top: 50%;
left: 0;
}
<div class="line-container">
<i class="arrow right in"></i>
<div class="line"></div>
<i class="arrow left in"></i>
</div>
<div class="line-container">
<i class="arrow left out"></i>
<div class="line"></div>
<i class="arrow right out"></i>
</div>

How to add a box shadow to a css generated arrow?

I'm having difficulty adding a box shadow around the outline of the arrow that was generated using border properties. Is there a way to make the box shadow in the shape the same as the arrow instead of a square box?
Here's a jsfiddle.
HTML:
<a class="bx-prev"></a>
<a class="bx-next"></a>
CSS:
.bx-prev, .bx-next {
border-right: 15px solid green;
border-bottom: 15px solid green;
width: 35px;
height: 35px;
top: 200px;
box-shadow: 0 0 10px 0 rgba(0,0,0,0.5);
}
.bx-prev {
transform: rotate(135deg);
position: absolute;
left: 220px;
}
.bx-next {
transform: rotate(-45deg);
position: absolute;
left: 320px;
}
Try this.
Edit!
.bx-prev, .bx-next {
border-right: 15px solid green;
border-bottom: 15px solid green;
width: 35px;
height: 35px;
top: 200px;
-webkit-filter: drop-shadow(0px 0px 2px rgba(0,0,0,.7));
filter: drop-shadow(0px 0px 2px rgba(0,0,0,.7));
}
.bx-prev {
transform: rotate(135deg);
position: absolute;
left: 220px;
}
.bx-next {
transform: rotate(-45deg);
position: absolute;
left: 320px;
}
<a class="bx-prev"></a>
<a class="bx-next"></a>
You can try the blur filter by creating the same arrow with a pseudo element:
.bx-prev,
.bx-next {
top: 200px;
position:relative;
}
.bx-prev {
transform: rotate(135deg);
position: absolute;
left: 220px;
}
.bx-next {
transform: rotate(-45deg);
position: absolute;
left: 320px;
}
/*the arrow*/
.bx-prev:before,
.bx-next:before,
.bx-prev:after,
.bx-next:after{
content:"";
position:absolute;
border-right: 15px solid green;
border-bottom: 15px solid green;
width: 35px;
height: 35px;
}
/*the shadow*/
.bx-prev:after,
.bx-next:after{
border-color: red;
z-index:-1;
filter:blur(5px);
}
<a class="bx-prev"></a>
<a class="bx-next"></a>

putting a point on the right side of a div

I am trying to put a point on the right side of a relative (no defined width) div.
HTML (using Wordpress and Bootstrap)
<div class="col-md-9 col-md-offset-1">
<h2 class="sml-title"><?php the_category(' - '); ?></h2>
...
CSS
.sml-title {
display: inline-block;
padding: 15px;
color: #fff;
background-color: #4ad2dc;
}
.sml-title:after {
right: 0px;
top: 0px;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-left-color: #88b7d5;
border-width: 30px;
margin-top: -30px;
}
the problem I'm running into is that the arrow goes all the way to the right side of the screen. I want it to go right after the sml-title. But I can't set a width on the sml-title because i don't control the content.
Trying to accomplish this
You can achieve the shape as either of the two ways-
.arrow {
border-right: 33px solid transparent;
height: 0;
width: 130px;
border-bottom: 34px solid black;
}
.invert {
-moz-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: transform: rotateX(180deg);
;
}
#base {
background: red;
display: inline-block;
height: 134px;
margin-left: 33px;
/* margin-top: 51px; */
position: relative;
width: 70px;
transform: rotate(90deg);
}
#base:before {
border-bottom: 35px solid red;
border-left: 36px solid transparent;
border-right: 34px solid transparent;
content: "";
height: 0;
left: 0;
position: absolute;
top: -35px;
width: 0;
}
<div class="arrow"></div>
<div class="arrow invert"></div>
<div id="base"></div>
h2{
background: #000;
color: #fff;
float: left;
font-family: Arial, sans-serif;
overflow: hidden;
padding: 20px 50px 20px 20px;
position: relative;
text-align: center;
min-width: 200px;
}
h2:before, h2:after {
content: '';
display: block;
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid #fff;
position: absolute;
right: -10px;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
h2:before {
top: -20px;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
h2:after {
bottom: -20px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<h2 class="sml-title">TITLE</h2>
If you use position: absolute, it will position the element within the nearest parent which is either position: relative or absolute. In your case, .sml-title has neither of those properties, so .sml-title:after is not positioned within .sml-title.
If you want your ::after pseudoelement to be positioned within .sml-title, you'll need to add position: relative or absolute to .sml-title

CSS Arrowhead down arrow

I'm having so much trouble getting this arrow designed how I want.
Right now I'm stuck with a solid triangle and I'm trying to turn it into a "hairline" arrow, like so: http://davidkelley.me/2013/03/01/css-hairline-arrows.html.
Fiddle
.hairline-down-arrow {
border: 1px solid black;
border-radius: 50%;
width: 65px;
height: 65px;
background-color: white;
}
.hairline-down-arrow:after {
content: "";
position: relative;
top: 44px;
left: 15px;
border-top: solid 25px black;
border-right: solid 15px transparent;
border-bottom: solid 25px transparent;
border-left: solid 15px transparent;
}
<section class="hairline-down">
<div class="hairline-down-arrow"></div>
</section>
Any help?
Thanks.
Why not just use an svg?
<svg width="70" height="55" viewBox="-2.5 -5 75 60" preserveAspectRatio="none">
<path d="M0,0 l35,50 l35,-50" fill="none" stroke="black" stroke-linecap="round" stroke-width="5" />
</svg>
Or you could use a :pseudo-element.
div {
position: relative;
width: 80px;
height: 1px;
background: black;
transform: rotate(55deg);
transform-origin: 0% 0%;
}
div:after {
content: '';
position: absolute;
width: 100%;
height: 100%;
bottom: 0;
left: 100%;
background: black;
transform: rotate(-110deg);
transform-origin: 0% 100%;
}
<div></div>
you can use border for pseudo element and rotate,skew so that it
.hairline-down-arrow {
border: 1px solid black;
border-radius: 50%;
width: 65px;
height: 65px;
position: relative;
background-color: white;
}
.hairline-down-arrow:after {
content: "";
position: absolute;
top: 4%;
left: 54%;
width: 30px;
height: 30px;
border-width: 0px 1px 1px 0px;
transform: rotate(46deg) translate(-50%) skew(10deg, 10deg);
transform-origin: left;
border-style: solid;
border-color: black;
}
<div class="hairline-down-arrow"></div>
Hey i just make it for left direction you can do some little change to move in any direction.
.leftchat:after {
content: "";
position: absolute;
top: 6px;
left: -7px;
border-style: solid;
border-width: 5px 7px 5px 0;
border-color: transparent #fff;
display: block;
width: 0;
height:0
}
.leftchat:before{
content: "";
position: absolute;
top: 2px;
left: -12px;
border-style: solid;
border-width: 8px 11px 8px 0;
border-color: transparent #D1D2D4;
display: block;
width: 0;
height:0;
z-index: 0
}
I created a CSS only downarrow:
http://jsfiddle.net/x3802ox3/
<div class="link">This is text with a downarrow<div class="arrow"></div></div>
.link {
position: relative;
display: inline-block;
padding-right: 27px;
font-size: 18px;
}
.arrow {
position: absolute;
right: 0;
top: 11px;
display: block;
width: 20px;
}
.arrow:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 2px;
width: 12px;
background: #000000;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
transform: rotate(40deg);
}
.arrow:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 12px;
background: #000000;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
transform: rotate(-40deg);
}
Live demo
Plain CSS
.arrow {
display: inline-block;
position: relative;
margin: 1em;
}
.arrow.thin.up {
border-top: 1px solid #fff;
border-left: 1px solid #fff;
height: 40px;
width: 40px;
transform: rotate(45deg);
}
.arrow.thin.left {
border-top: 1px solid #fff;
border-left: 1px solid #fff;
height: 40px;
width: 40px;
transform: rotate(135deg);
}
.arrow.thin.down {
border-top: 1px solid #fff;
border-left: 1px solid #fff;
height: 40px;
width: 40px;
transform: rotate(225deg);
}
.arrow.thin.right {
border-top: 1px solid #fff;
border-left: 1px solid #fff;
height: 40px;
width: 40px;
transform: rotate(315deg);
}
or as a SASS mixin
#mixin arrow($color, $direction: down, $size: 10px) {
border-top: 1px solid $color;
border-left: 1px solid $color;
height: $size;
width: $size;
#if $direction == 'up' {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
} #else if $direction == 'left' {
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
transform: rotate(135deg);
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=-0.7071067811865475, M12=0.7071067811865476,M21=-0.7071067811865475,M22=0.7071067811865476);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.7071067811865475, M12=0.7071067811865476,M21=-0.7071067811865475,M22=0.7071067811865476)";
} #else if $direction == 'down' {
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
transform: rotate(225deg);
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=-0.7071067811865477, M12=-0.7071067811865475,M21=-0.7071067811865477,M22=-0.7071067811865475);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.7071067811865477, M12=-0.7071067811865475,M21=-0.7071067811865477,M22=-0.7071067811865475)";
} #else if $direction == 'right' {
-webkit-transform: rotate(315deg);
-moz-transform: rotate(315deg);
transform: rotate(315deg);
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=0.7071067811865474, M12=-0.7071067811865477,M21=0.7071067811865474,M22=-0.7071067811865477);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865474, M12=-0.7071067811865477,M21=0.7071067811865474,M22=-0.7071067811865477)";
}
}
body {
background: #000;
text-align: center;
padding: 5em;
}
.arrow {
display: inline-block;
position: relative;
margin: 1em;
}
.arrow.thin.up {
#include arrow($direction: up, $color: #fff, $size: 40px);
}
.arrow.thin.left {
#include arrow($direction: left, $color: #fff, $size: 40px);
}
.arrow.thin.down {
#include arrow($direction: down, $color: #fff, $size: 40px);
}
.arrow.thin.right {
#include arrow($direction: right, $color: #fff, $size: 40px);
}