How to create breadcrumb shape - html

I've been trying to create a breadcrumb in the shape of an arrow that has a point on one end and a tail at the other.
Basically, the layout is: [tail][body][point], where tail & point are just triangles.
I managed to create [body][point] using css, but i'm stuck trying to make the tail to work. Can this also be done with css?
DEMO: https://plnkr.co/edit/mQELiNgVCe6ZoTepCtr9?p=preview
The HTML:
<div style="font-size:0">
<div class="arrow-tail"></div>
<div class="arrow-body">HELLO WORLD!</div>
<div class="arrow-point"></div>
</div>
The CSS:
.arrow-point {
display: inline-block;
width: 0;
height: 0;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #777777;
}
.arrow-body {
font-family: verdana;
font-size:15px;
display: inline-block;
background-color: #777777;
color:white;
padding:2px 6px 2px 16px;
height:20px;
vertical-align:top;
}
.arrow-tail {
float:left;
display: inline-block;
width: 0;
height: 0;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #EEEEEE;
}

Its a bit difficult to understand how you want the final result to look like based on the information you provided in the original post. But I make some guesses and I believe that you want it to look like this:
You can achieve this by setting the tail to position: absolute.
The final CSS of the tail would be this:
.arrow-tail {
position: absolute;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
border-left: 15px solid #fff;
}
Also note that if you want to move around your tail with the top:, right:, bottom:, left: attributes then you need to make sure that the container div is set to position: relative.

Related

Why do my standard CSS Triangles have their points cut off?

So I have the following two triangles:
The points are cut off, but my code is literally just this:
.navCaret {
position: relative;
float: right;
right: 5px;
top: 5px;
width: 0;
height: 0;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 9px solid #ccc;
}
.navCaretOL {
position: relative;
float: right;
right: 9px;
top: 9px;
width: 0;
height: 0;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 9px solid #333;
}
And as you can see in this JSFiddle, it actually DOESN'T cut the edges off when rendering these triangles in a JSFiddle.
All in all this could not be a more standard way of creating a pure CSS triangle and has worked for me many, many times. Anyone have any idea what could be causing this strange behavior? Thanks.
EDIT: By the way, confirmed to behave the same way in IE and Chrome, both latest versions.
OMG I just figured this out by going through my page and deleting each CSS rule line-by-line. Apparently the problem was caused by the following rule:
div.navUpper * {
padding-top: 4px;
}
'.navUpper' is the container my carets were in. The '*' selector was applying 4px padding to them -- the effects of which can be seen here: https://jsfiddle.net/6f4yxp4e/8/
Thanks again to those who responded -- you were both right in different ways.
The triangle is only pointy when the border stretches all the way to the center, meaning anything altering the content box has to be 0 - this includes width/height and padding. Check for other css rules that overwrite your height: 0; or add some padding.
.navCaret {
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 9px solid #ccc;
outline: 1px solid red; /*for illustration purposes only*/
}
.navCaretOL {
height: 0;
width: 0;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 9px solid #333;
white-space: nowrap; /*for illustration purposes only*/
outline: 1px solid red; /*for illustration purposes only*/
}
<div class="navCaret">height != 0</div>
<br>
<div class="navCaretOL">height == 0 (content is overflowing)</div>

making border have a angle

I am traying to make an angled border, I made a quick paint-ish design on what I mean or try to say :
The green is a logo,centered in the middle.
The paurple are DIV's, the white is white space.
I want the purple DIVs to have those angled edges! I have NO idea how to do this.
I searched for some angled css border but I only found shapes, but I dont understand how it works after reading :/
Anyone that can give me a hand or point me in the right direction? Thanks a Bunch!
I wouldn't try to smash the purple divs into those shapes. I would recommend an HTML setup like this:
<span class="triangle-1"></span>
<div>
<span class="triangle-2"></span>
<span class="logo"></span>
<span class="triangle-3"></span>
</div>
<span class="triangle-4"></span>
And make CSS shapes with the white triangles--a much easier task in CSS. Here's CSS for a perfectly responsive example, which may or may not be what you want:
body {
background: #652f70;
font-size: 0;
margin: 0;
text-align: center;
}
span {
display: inline-block;
}
.triangle-1 {
border-top: 40vh solid #fff;
border-left: 90px solid transparent;
border-right: 90px solid transparent;
}
.triangle-2 {
border-left: 33vw solid #fff;
border-top: 10vh solid transparent;
border-bottom: 10vh solid transparent;
position: absolute;
left: 0;
}
.logo {
background: #78bd52;
height: 20vh;
width: 34vw;
}
.triangle-3 {
border-right: 33vw solid #fff;
border-top: 10vh solid transparent;
border-bottom: 10vh solid transparent;
position: absolute;
right: 0;
}
.triangle-4 {
border-bottom: 40vh solid #fff;
border-left: 90px solid transparent;
border-right: 90px solid transparent;
}
And here's a JSFiddle

How to I get Orange Bar on the top of my banner instead of on the top of the page

I'm trying to position a 10px height orange bar on the top of my HTML banner. When I put in the code the orange bar is displayed, but it's displayed on the top of the window. How do I move it so it's displayed on the top of the HTML banner? I'd like it in the "Top 10 Wi-Fi Routers" banner
see my jsfiddle: http://jsfiddle.net/huskydawgs/tKn9f/77/
<div id="wrapper-landing">
<p>
A Wi-Fi router is at the center of most people's home networks, but not every router is a good one. It's been a while since we last looked at the best Wi-Fi routers on the market, this week we want to take a fresh look and build a better top five list.</p>
<div class="box-promo-row">
<div class="box-promo-orange"></div>
<h3>
Top 10 Wi-Fi Routers</h3>
<span class="box-promo-content">
The last time we talked about Wi-Fi routers, 802.11ac wasn't really a thing yet, and now that it is and routers that support it have come down in price, it's time to take a fresh look. This week we want to know which routers you think offer the best combination of speed, range, features, customization options, and as always, bang for the buck.</span>
</div>
</div>
</div>
#wrapper-landing {
width: 916px;
margin: 0 auto 50px auto;
padding: 0;
}
#wrapper-landing p {
color: rgb(102, 102, 102);
font-family: 'SegoeRegular',Helvetica,Arial,sans-serif;
font-size: 1.1em;
line-height: 1.6em;
}
.box-promo-row {
width:893px;
margin: 0;
padding: 30px;
border-left: 1px solid #e2e3e4;
border-right: 1px solid #e2e3e4;
border-bottom: 1px solid #e2e3e4;
margin-top: 0;
margin-bottom: 0;
background-color: #e2e3e4;
box-shadow: 1px 2px 0px rgba (0,0,0,0.15);
}
.box-promo-row h3 {
font-family:SegoeBold, Helvetica, Arial;
font-size:1.3em;
color:#2251a4;
margin: 0 0 2px 0;
}
.box-promo-content {
color: #616161;
font-family: 'SegoeRegular',Helvetica,Arial,sans-serif;
font-size: 1em;
line-height: 1em;
}
.box-form-body {
display: inline-block;
width: 100%;
}
.box-promo-orange {
position: absolute;
content: "";
width: 100%;
height: 10px;
background: #f66511;
left: -1px;
top: 0;
z-index: 20px;
border: 1px solid #f66511;
}
You'd have to use relative positioning on .box-promo-row
or
you don't use a separate element at all and use an orange border?
.box-promo-now{
border-top: 10px solid orange;
}
please update this code with your CSS and the orange line will come just above the header..
.box-promo-row {
position:relative; /*Added this line*/
width:893px;
margin: 0;
padding: 30px;
border-left: 1px solid #e2e3e4;
border-right: 1px solid #e2e3e4;
border-bottom: 1px solid #e2e3e4;
margin-top: 0;
margin-bottom: 0;
background-color: #e2e3e4;
box-shadow: 1px 2px 0px rgba (0,0,0,0.15);
}
.box-promo-row:before {
position: absolute;
content: " ";
width: 100%;
height: 10px;
background: #f66511;
left: -1px;
top: 0;
z-index: 20px;
border: 1px solid #f66511;
}
Here is the Working Demo. http://jsfiddle.net/kheema/tKn9f/87/
Your .box-promo-orange CSS should set position: relative instead of absolute. Absolute means it positions it relative to the whole page. Relative positions it relative to the parent container (in this case box-promo-row).
Use
.box-promo-row {
position: relative;
}

Trim a small empty triangle on top of a div

I'm trying to make a drop down menu, without any images, Pure CSS and HTML like the following:
What I'm not able to do is make this little Triangle shaped trim on Top
is it possible in CSS, if it is, how?
Live Example: http://jsbin.com/owafod/1/
I used CSS triangle generator to create the triangle.
#Nav {
width: 300px;
height: 200px;
background: #333;
}
#Triangle {
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 10px 0 10px;
border-color: #ffffff transparent transparent transparent;
margin: 0 auto;
}
Here's a solution with borders :
Result :
HTML :
<div id=a></div><div id=b></div>
<div id=c></div>
CSS :
#a {
border-right: 5px solid white;
border-bottom: 5px solid black;
width: 100px;
display: inline-block;
margin:0;
}
#b {
border-left: 5px solid white;
border-bottom: 5px solid black;
width: 100px;
display: inline-block;
margin:0;
}
#c {
background: black; height:20px;width:210px
}
Tests
And here's a picture that will probably suffice to explain how it's made and how you can easily use this kind of border trick :
(the code to make it)

How to draw vertical line and horizontal markers

How can I make a vertical line and horizontal markers (an L shape) using CSS:
something like:
Test
L T2
L t3
You don't need a div for this, because you have pseudo-elements! Here's a quick example I threw together, and you can find a working sample here: http://jsbin.com/aladez/2
HTML:
<ul>
<li>Herp</li>
<li>Derp</li>
<li>Derp</li>
</ul>
CSS:
li {
list-style: none;
}
li:before {
content: "";
position: relative;
top: -6px;
font-size: 4px;
line-height: 4px;
padding: 4px 8px 0 0;
margin: 0 10px 0 0;
border-bottom: 1px solid #000;
border-left: 1px solid #000;
}
Create a div with the following css:
width: 20px; //or whatever width you want for the horizontal line
height: 40px; //or whatever height you want for the vertical line
border-bottom: 1px solid black;
border-left: 1px solid black;
and plant it where you want.
Well, you could add a div and set the border as div { border-left: 1px solid; border-bottom: 1px solid; }. Adjust width and height of that div till it fits your needs. You would also want to make sure that you set float: left for the div.
I don't think there is a solution in html which works OOTB.