Arrow not showing properly in CSS - html

I am trying to achieve the arrow pointing downwards...
right now its showing as trapezium there is some problem in CSS arrow code...
providing my code below.....
Output
https://docs.google.com/file/d/0B3IBJKENGE7RRFR1WHZDYTF6LTQ/edit
<div class="icon__controls__controls">
<div><i class="zoom-out"></i>
<i class="icon-threesixty"></i>
</div>
</div>
CSS :
.icon__controls__controls {
float: left;
display: block;
margin-right: 2.1276595745%;
width: 36.170212766%;
margin-left: 38.2978723404%;
margin-top: 10px;
margin-bottom: 30px;
text-align: center;
}
.icon__controls__controls:last-child {
margin-right: 0;
}
.icon__controls__controls [class^=icon-] {
font-size: 20px;
font-size: 1.25rem;
display: inline-block;
vertical-align: baseline;
zoom: 1;
*display: inline;
*vertical-align: auto;
color: #666;
margin: 0 5px;
vertical-align: top;
}
.icon__controls__controls .zoom-out {
color: red;
}
.icon__controls__controls:after {
display: none;
content: '';
z-index: 3;
border: 50px solid transparent;
/* border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black; */
}
.icon__controls__controls:after {
border-top-color: #ef6f00;
}
.icon__controls__controls.active:after {
display: block;
}

LIVE DEMO
This as basically all what you need to understand how it works:
STYLE:
.arrow{
width:20px;
height:20px;
position:relative;
}
.arrow:before{
content:'';
position:absolute;
top:0;
left:0;
width:0;
height:0;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-bottom:0px solid transparent;
border-top:20px solid orange;
}
HTML:
<div class=arrow><div>
if you want it to point up just switch topand bottom
border-top:0px solid transparent;
border-bottom:20px solid orange;
Same for leftand right.
I hope this will help you understanding how arrow are created.

Basic sample :
<div class="arrowBorder"></div>
.arrowBorder {
height : 0px;
width : 0px;
border-top: 50px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
}
http://jsbin.com/qusecu/4/watch?html,css,output
see more - CSS clipping or masking

You should find the below bit more simpler
css
.arrow{
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-o-box-sizing:border-box;
-ms-box-sizing:border-box;
width:20px;
height:20px;
position:relative;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-bottom:20px solid transparent;
border-top:20px solid orange;
}
html
<div class=arrow><div>

Related

Border styles on unique button shape

I am attempting to align the border of the pseudo-element to evenly match the border of the button. I am using ::before and ::after pseudo-elements overlaid to get this effect, but they do not properly match the rest of the border.
I have messed around with the left and right positioning as well as the border-width of each element, but can't seem to get them to line up perfectly
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.btn-txt{
color: black;
}
button {
border: none;
outline: none;
padding: 0;
border-width: 0;
left: 40%;
}
button:hover {
cursor: pointer;
}
.signpost { /* our rectangle */
width:250px;
height:50px;
background-color: yellow;
margin:0px auto;
position: relative;
border-top: 2px solid red;
border-bottom: 2px solid red;
border-left: 2px solid red;
}
.signpost:after { /* our pseudo-element */
content:"";/* required */
position: absolute; /* takes the 'cap' out off flow */
top:0%; /* stick it to top edge of the sign */
left:81%; /* push it way overto the right*/
height:0; /* we're doing this with borders remember */
width:0;
border-width: 25px;
border-style:solid;
border-color: #fff; /* same as bg of our rectangle */
/* now we make some of theborders disappear*/
border-top-color:transparent;
border-bottom-color:transparent;
border-left-color:transparent;
}
.signpost:before { /* our pseudo-element */
content:"";/* required */
position: absolute; /* takes the 'cap' out off flow */
top:0%; /* stick it to top edge of the sign */
left:80%; /* push it way overto the right*/
height:0; /* we're doing this with borders remember */
width:0;
border-width: 25px;
border-style:solid;
border-color: red; /* same as bg of our rectangle */
/* now we make some of theborders disappear*/
border-top-color:transparent;
border-bottom-color:transparent;
border-left-color:transparent;
}
<button class="signpost">
<p class="btn-txt">HELLO</p>
</button>
Example of current issue: https://codepen.io/codingforthefuture/pen/YzKeeVJ
Here is a different idea with less of code where the alignment will be easy to handle:
.box {
display:inline-block;
position:relative;
margin:10px;
padding:10px 50px 10px 10px;
border:2px solid red;
border-right:0;
z-index:0;
background:linear-gradient(yellow,yellow) left/calc(100% - 40px) 100% no-repeat;
}
.box:before,
.box:after{
content:"";
position:absolute;
z-index:-1;
right:0;
width:40px;
top:0;
bottom:50%;
border-right:2px solid red;
background:yellow;
transform:skewX(-45deg);
transform-origin:top;
}
.box:after {
transform:skewX(45deg);
transform-origin:bottom;
top:50%;
bottom:0;
}
<div class="box"> some text </div>
<div class="box"> some long long text </div>
<div class="box"> some long <br> long text </div>
I think I came to a suitable solution. From my original attempt I made the pseudo elements complete squares and rotated them 45deg, then overlapped them. I think this resolves the issues when zooming in and out too. It also makes the edges of the flag pointed instead of squared off, which I think looks better.
#flag4 {
width: 200px;
height: 56px;
box-sizing: content-box;
padding-top: 15px;
position: relative;
background: yellow;
color: white;
font-size: 11px;
letter-spacing: 0.2em;
text-align: center;
text-transform: uppercase;
border-top: 1px solid red;
border-bottom: 1px solid red;
border-left: 1px solid red;
margin-bottom: 20px;
}
#flag4::before,
#flag4::after {
content: "";
position: absolute;
top: 10px;
width: 0;
height: 0;
left: 87.2%;
border-right: 26px solid #fff;
border-top: 26px solid #fff;
border-bottom: 25px solid #fff;
border-left: 25px solid #fff;
transform: rotate(45deg);
}
#flag4::before{
border-right: 26px solid red;
border-top: 26px solid red;
border-bottom: 25px solid red;
border-left: 25px solid red;
left: 86.6%;
}
codepen: https://codepen.io/codingforthefuture/pen/WNezNzZ

Make a right outer curved layer for paragraph with CSS

I am trying to make a list of paragraphs, and one of them should be selected, just like the image below, but it seems I just cannot succeed.
I have tried something at: http://jsfiddle.net/bmj2j2wd/ but the end just just does not curve the way I would like it to... ie outwards, not inwards.
This is the css from there:
.active{
border:2px solid dodgerblue;
border-bottom:0;
width:80px;
height:32px;
margin:10px;
position:relative;
border-radius:16px 16px 0 0;
}
.active:after,
.active:before{
content:'';
width:80px;
height:32px;
border:2px solid dodgerblue;
position:absolute;
bottom:-8px;
border-top:0;
}
.active:after{
border-left:0;
border-radius:0 0 16px 0;
down:-16px;
}
.active:before{
border-right:0;
border-radius:0 0 0 16px;
up:-16px;
}
but it looks totally not right.
Very important would be that the two right lines after the curvature would go all the way up and down till the top and bottom of the page.
So, I'd like to ask for some help from the community in order to get this working.
You can basically use :before and :after to create a box on top and a box on bottom of your active <p> element (p.active). With these two boxes you can change the direction of the border. The following shows an example with a dynamic length based on the elements (Code on JSFiddle):
See the following solution (the original answer before edit):
.container :not(.active) {
border-right:1px solid dodgerblue;
margin:0;
padding:10px 10px 10px 20px;
width:72px;
}
.active {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
height:32px;
line-height:32px;
margin:10px;
padding-left:10px;
position:relative;
width:80px;
}
.active:after, .active:before {
border-right:1px solid dodgerblue;
content:'';
height:32px;
right:-2px;
position:absolute;
width:80px;
}
.active:after {
border-bottom-right-radius: 5px;
transform:translateY(-100%);
}
.active:before {
border-top-right-radius:5px;
transform:translateY(100%);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
</div>
You want to set vertical border on the full height of the page. This is a very difficult thing but you can use the following solution using a container which hides the overflow (the too long borders) (Code on JSFiddle):
body, html {
margin:0;
padding:0;
}
.container {
height:100vh;
margin:0;
overflow:hidden;
padding:0;
}
p {
display:block;
height:32px;
line-height:32px;
margin:10px;
padding:0;
padding-left:10px;
}
.active {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
position:relative;
width:80px;
}
.active:after, .active:before {
border-right:1px solid dodgerblue;
content:'';
height:100vh; /** same height like container */
position:absolute;
right:-2px;
width:80px;
}
.active:after {
border-bottom-right-radius:5px;
transform:translateY(-100%);
}
.active:before {
border-top-right-radius:5px;
transform:translateY(32px);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
<p>item7</p>
</div>
An additional, maybe useful, example using :hover instead of .active to set the active element. This is useful for tests too (Code on JSFiddle):
body, html {
margin:0;
padding:0;
}
.container {
height:80vh;
margin:0;
overflow:hidden;
padding:0;
}
p {
border:1px solid transparent;
display:block;
height:32px;
line-height:32px;
margin:10px;
padding:0;
padding-left:10px;
}
p:hover {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
position:relative;
width:80px;
}
p:hover:before, p:hover:after {
border-right:1px solid dodgerblue;
content:'';
height:100vh; /** same height like container */
position:absolute;
right:-2px;
width:80px;
z-index:-1;
}
p:hover:after {
border-bottom-right-radius:5px;
transform:translateY(-100%);
}
p:hover:before {
border-top-right-radius:5px;
transform:translateY(32px);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
<p>item7</p>
</div>
You could use :after and :before pseudo elements and add border-radius.
.active {
padding: 15px;
margin: 60px;
border: 1px solid blue;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
padding-right: 0;
display: inline-block;
border-right: none;
position: relative;
}
.active:before,
.active:after {
content: '';
position: absolute;
width: 30px;
height: 40px;
}
.active:before {
border-right: 1px solid blue;
border-bottom: 1px solid blue;
border-bottom-right-radius: 50%;
right: -30px;
top: 0;
transform: translateY(-100%);
}
.active:after {
border-right: 1px solid blue;
border-top: 1px solid blue;
border-top-right-radius: 50%;
right: -30px;
bottom: 0;
transform: translateY(100%);
}
<div class="active">Some selection</div>
Another option that uses span elements for the curved lines, instead of pseudoelements
fiddle
body {
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.active {
border: 1px solid red;
border-right: 0;
width: 80px;
height: 32px;
position: relative;
border-radius: 5px 0 0 5px;
display: flex;
align-items: center;
padding-left: 1em;
}
.curvy {
flex: 1;
width: 80px;
margin-left: 30px;
border: 1px solid red;
border-left: 0;
border-top: 0;
border-radius: 0 0 5px 0;
margin-bottom: -1px;
}
.active+.curvy {
margin-bottom: 0;
margin-top: -1px;
border-top: 1px solid red;
border-radius: 0 5px 0 0;
border-bottom: 0;
}
<span class="curvy"></span>
<div class="active">hi</div>
<span class="curvy"></span>
While the other two works but it was not all the way up & down.
To make the line longer/shorter, change the height & top value.
height: 50vh;
top: calc(-50vh - 1px);
.active{
border:1px solid red;
border-right:0;
width:80px;
height:32px;
margin: 150px auto 0;
position:relative;
border-radius: 10px 0px 0 10px;
padding: 10px;
}
.active:after,
.active:before {
content: '';
position: absolute;
width: 20px;
height: 50vh;
}
.active:before {
top: calc(-50vh - 1px);
right: -20px;
border-bottom-right-radius: 10px;
border: 1px solid red;
border-left: none;
border-top: none;
}
.active:after{
bottom: calc(-50vh - 1px);
right: -20px;
border-top-right-radius: 10px;
border: 1px solid red;
border-left: none;
border-bottom: none;
}
<div class="active">hi</div>

How to force an element above another

I have two slightly overlapping (breadcrumb) elements, side-by-side, and I want to make the one on the left to clip the one on the right. Setting z-index didn't appear to work. Is there a better way?
DEMO:https://plnkr.co/edit/5RCH9hswONT16QJeK3KE?p=preview
.arrow-point {
display: inline-block;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #777;
/* z-index:10; */
}
.arrow-body {
font-family: verdana;
font-size:15px;
display: inline-block;
background-color: #777;
color:white;
padding:2px 6px 2px 20px;
height:20px;
vertical-align:top;
/* z-index:-3; */
}
.arrow-tail {
position: absolute;
display: inline-block;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #FFF;
/* z-index:-2; */
/* margin-left:-6px; */
}
<div style="font-size:0;display:inline-block">
<div class="arrow-tail"></div>
<div class="arrow-body">Submenu A</div>
<div class="arrow-point"></div>
</div>
<div style="font-size:0;float:left;margin-right:-6px;display:inline-block">
<div class="arrow-body">Main Menu</div>
<div class="arrow-point"></div>
</div>
Set position to relative. Than set z-index: 9999.
The position property specifies the type of positioning method used for an element.
.arrow-point {
display: inline-block;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #777;
/* z-index:10; */
}
.arrow-body {
font-family: verdana;
font-size:15px;
display: inline-block;
background-color: #777;
color:white;
padding:2px 6px 2px 20px;
height:20px;
vertical-align:top;
/* z-index:-3; */
}
.arrow-tail {
position: absolute;
display: inline-block;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #FFF;
/* z-index:-2; */
/* margin-left:-6px; */
}
<div style="font-size:0;display:inline-block">
<div class="arrow-tail"></div>
<div class="arrow-body">Submenu A</div>
<div class="arrow-point"></div>
</div>
<div style="font-size:0;float:left;margin-right:-6px;display:inline-block;position: relative;z-index: 9999;">
<div class="arrow-body">Main Menu</div>
<div class="arrow-point"></div>
</div>
Assuming that all these menus are inside a container div, set the parent style to float:left; and have the children float:right. Please ensure that the order must be reversed. Take a look.
.container{
position:relative;
float:left;
}
.container > div{
position: relative;
margin-left: -15px;
z-index: 10;
font-size: 0;
display: inline-block;
float: right;
}
.container > div:last-child{
margin-left:0;
}
.arrow-point {
display: inline-block;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #777;
/* z-index:10; */
}
.arrow-body {
font-family: verdana;
font-size:15px;
display: inline-block;
background-color: #777;
color:white;
padding:2px 6px 2px 20px;
height:20px;
vertical-align:top;
/* z-index:-3; */
}
.arrow-tail {
position: absolute;
display: inline-block;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #FFF;
/* z-index:-2; */
/* margin-left:-6px; */
}
<div class="container">
<div>
<div class="arrow-tail"></div>
<div class="arrow-body">Submenu B</div>
<div class="arrow-point"></div>
</div>
<div>
<div class="arrow-tail"></div>
<div class="arrow-body">Submenu A</div>
<div class="arrow-point"></div>
</div>
<div>
<div class="arrow-body">Main Menu</div>
<div class="arrow-point"></div>
</div>
</div>

Slider Header using CSS

I have been trying to create an image like this using css.
which I partly achieved like this
<div class="nav-tab">
<div class="arrow-left"></div>
<div class="arrow"></div>
<div class="arrow-right"></div>
</div>
CSS
div {
float: left;
margin: 0;
padding: 0;
}
.arrow {
background-color: green;
height: 60px;
width: 240px;
}
.arrow-right {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid green;
}
.arrow-left {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid white;
position: relative;
left: 30px;
}
Fiddle: https://jsfiddle.net/codeandcloud/g3cmgw8y/6/
But the design has these problems
1) The arrow-left not having background-color transparent. ( Is it possible as per this design? )
2) What I want is to use it as the image below. When I put each .nav-tab in a ul > li with float:left the output is garbled.
Fiddle: https://jsfiddle.net/g3cmgw8y/7/
What am I doing wrong and how should I fix this.
How about using skew instead?
https://jsfiddle.net/foreyez/1gf3zam3/
<div class='arrow'>
<div class='arrowtop'>
</div>
<div class='arrowbottom'>
</div>
</div>
.arrowtop {
transform: translateX(50px) skewX(45deg);
width:400px;
height:50px;
background:red;
}
.arrowbottom {
transform: translateX(50px) skewX(-45deg);
width:400px;
height:50px;
background:red;
}
Hmm ... maybe this's an answer ?
.arrow-left {
border-top: 30px solid green;
border-bottom: 30px solid green;
border-left: 30px solid transparent;
position:relative;
left: 0px;
}

What is causing this oblique border issue?

I am trying to remove oblique border issue, best to show it in a picture:
Here is the css applied to the div:
.blog_post {background: #fff}
.blog_post .post {
border-right-color: #F1F1F1;
border-top-color: #FF0000;
}
.blog_post .post, .blog_post .sidebar {
background: none repeat scroll 0 0 #FFFFFF;
border-color: #FFFFFF;
border-width: 10px;
}
.blog_post .post {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: none repeat scroll 0 0 #9A9570;
border-color: #8F8960 #8F8960 -moz-use-text-color;
border-image: none;
border-style: solid;
border-width: 10px;
float: left;
margin: -560px 0 0 -12px;
padding: 28px 30px;
position: relative;
width: 528px;
z-index: 9;
}
Any help would be greatly appreciated.
Easy way: Another container
You can't do this with traditional HTML borders as they work at shown above (that's how CSS triangles work!). The easiest way to get this effect is to wrap the element in another container.
Demo
HTML
<div class="container">
<div class="inner-container">
...
</div>
</div>
CSS
.container {
border-top:10px solid red;
border-bottom:10px solid red;
}
.inner-container {
border-left:10px solid blue;
border-right:10px solid blue;
}
Hard way: :before and :after
This method is a little more tricky but you can manage to pull it off with only one wrapping element.
Demo
HTML
<div class="container">
...
</div>
CSS
.container {
border-top:10px solid red;
border-bottom:10px solid red;
position:relative;
/* pad out the left and right to allow room for the border */
padding:0 10px;
}
.container:before,
.container:after {
position:absolute;
top:0;
bottom:0;
width:10px;
background-color:blue;
display:block;
content:"";
}
.container:before {
left:0;
}
.container:after {
right:0;
}
You can always use inset box shadows. They are pretty easy to use, and they don't require much CSS, nor do you have to change the HTML.
Check it out. jsFiddle here
div {
box-shadow: inset 0px 10px 0px red;
border: 10px solid blue;
border-top: 0px;
}
Using pseudo-classes :before and :after
.border-fixed {
width: 300px;
height: 300px;
background: #EEE;
margin: 60px auto 0;
border: solid 10px #DDD;
border-top-color: #BBB;
position: relative;
}
.border-fixed:before,
.border-fixed:after {
content: "";
top: -10px;
left: -10px;
position: absolute;
width: 10px;
height: 10px;
background: #BBB;
}
.border-fixed:before {
right: -10px;
left: auto;
}