I know only rounded border way. Can't figure out how to create such kind of imageless ul li tabs.
As you see it's not exactly triangle: it's top and bottom sides kinda rounded. Is it possible to create something maximum similiar to the image below with css3? if yes, how?
Thank you in advance!
the markup :
first you have to define your makeup as follow:
<menu type=list>
<li>home</li>
<li>work</li>
</menu>
then use skew, rotate, box-shadow, border-radius and CSS Pseudo-elements as follow:
source: http://www.w3schools.com/css3/css3_2dtransforms.asp
http://www.w3schools.com/cssref/css3_pr_box-shadow.asp
http://www.w3schools.com/cssref/css3_pr_border-radius.asp
http://www.w3schools.com/css/css_pseudo_elements.asp
Demo1:http://jsfiddle.net/kougiland/mVu2z/5/
menu{
position:relative;
width:320px;
height:40px;
}
li{
float:left;
width:50%;
background-color:red;
list-style:none;
position:relative;
height:54px;
text-align:center;
line-height:50px;
color:white;
}
li:before,li:after{
position: absolute;
content: "";
height: 32px;
width: 32px;
border-radius: 4px;
background-color: red;
top: 11px;
-webkit-transform: rotate(45deg) skew(16deg,16deg);
-moz-transform: rotate(45deg) skew(16deg,16deg);
transform: rotate(45deg) skew(16deg,16deg);
}
li:before{
left:-15px;
}
li:after{
right:-15px;
}
li:nth-child(2):before{
box-shadow: 0px 0 0 black,-4px 4px 0 black;
}
Demo2: http://jsfiddle.net/kougiland/mVu2z/4/
the style:
menu{
position:relative;
width:320px;
height:40px;
}
li{
float:left;
width:50%;
background-color:red;
list-style:none;
position:relative;
height:54px;
text-align:center;
line-height:50px;
color:white;
}
li:before,li:after{
position: absolute;
content: "";
height: 26px;
width: 26px;
border-radius: 4px;
background-color: red;
top: 14px;
-webkit-transform: rotate(45deg) skew(30deg,30deg);
-moz-transform: rotate(45deg) skew(30deg,30deg);
transform: rotate(45deg) skew(30deg,30deg);
}
li:before{
left:-13px;
}
li:after{
right:-13px;
}
li:nth-child(2):before{
box-shadow: 0px 0 0 black,-4px 4px 0 black;
}
Demo3: http://jsfiddle.net/kougiland/mVu2z/
menu{
position:relative;
width:320px;
height:40px;
}
li{
float:left;
width:50%;
background-color:red;
list-style:none;
position:relative;
height:54px;
text-align:center;
line-height:50px;
color:white;
}
li:before,li:after{
position:absolute;
content:"";
height:40px;
width:40px;
border-radius:4px;
background-color:red;
top: 7px;
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
transform:rotate(45deg);
}
li:before{
left:-20px;
}
li:after{
right:-20px;
}
li:nth-child(2):before{
box-shadow: 0px 0 0 black,-4px 4px 0 black;
}
You can use CSS transform rotate property along with border-radius, here, I've rotated an :after pseudo, which is positioned absolute to the container element. And than am using border-radius for the curve.
Demo
div {
height: 30px;
width: 100px;
background: #f00;
position: relative;
margin: 100px;
}
div:after {
background-color: #f00;
content: "";
display: block;
height: 22px;
width: 22px;
transform: rotate(45deg);
border-radius: 0 10px 0 0;
right: -11px;
top: 4px;
position: absolute;
}
Sure!
Chris Coyier was wrote a cool code for this:
http://css-tricks.com/triangle-breadcrumbs
Related
I need some help.
How can I display the html code according to the attached image.
I tried modifying the css, but it's not ok
div {
margin:50px;
background-color: #c1c1c1;
border:#000 solid 1px;
position:relative;
}
div:after{
content:'';
width:24px;
height:24px;
background:#fff;
position:absolute;
-moz-transform:rotate(45deg);
-webkit-transform:rotate(45deg);
transform:rotate(45deg);
top:-12px;
left:50px;
border-right:#000 solid 2px;
border-bottom:#000 solid 2px;
}
<div></div>
Thank You
A bit of transform:skew() does it.
Unless you're targeting very old browsers, it's no longer necessary to include the vendor-specific prefixes on these rules; they're broadly supported. (Mozilla/Firefox and IE haven't needed the prefixes for 2d transforms since 2012; Safari since 2015).
div {
margin:50px;
background-color: #c1c1c1;
border:#000 solid 1px;
position:relative;
}
div:after{
content:'';
width:24px;
height:24px;
background:#fff;
position:absolute;
top:-12px;
left:50px;
border-bottom:#000 solid 2px;
border-left:#000 solid 2px;
transform:skew(0,-45deg)
}
<div></div>
Here is another way to have transparency:
div {
margin: 50px;
height: 2px;
background: linear-gradient(to right, #000 44px, transparent 44px, transparent 60px, #000 60px);
position: relative;
}
div:before,
div:after {
content: '';
width: 2px;
position: absolute;
top: 2px;
background: #000;
}
div:after {
height: 26px;
transform-origin: top right;
transform: rotate(45deg);
left: 60px;
}
div:before {
height: 19px;
top: 0px;
left: 42px;
}
body {
background: pink
}
<div></div>
First, I know there are similar questions available (like. Create concave corners in css) but they don't really cover this situation.
This is not about single cell/div element.
I have three blocks that will have some text content inside:
top-middle centered block (narrow)
middle-middle block (screen-wide)
bottom-middle centered block (narrow)
Basically something like a cross (text removed):
The outer corners (8) is straighforward but how could I achieve those inner ones (4)?
see bellow code, maybe it needs some adjustments but the idea is that you use pseudo-elements to make those inner borders
let me know if this is what you want
.colored {
background:yellow;
border:5px solid green;
width:100px;
height:100px;
box-sizing:border-box;
position:relative;
}
#content {
width:300px;
position:relative;
background:#000;
}
.top,.bottom { position:relative;margin:0 auto;clear:both}
.top { border-bottom:none}
.bottom { border-top:none}
.left { border-right:none}
.right { border-left:none;}
.colored.center { border:none;}
.left,.center,.right { float:left;}
.top { border-top-left-radius:10px;border-top-right-radius:10px;}
.bottom { border-bottom-left-radius:10px;border-bottom-right-radius:10px;}
.right { border-bottom-right-radius:10px;border-top-right-radius:10px;}
.left { border-bottom-left-radius:10px;border-top-left-radius:10px;}
.top:before {
position:absolute;
height:100%;
width:100%;
left:-100%;
top:5px;
content:"";
border-bottom-right-radius:10px;
border-right:5px solid green;
border-bottom:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.top:after {
position:absolute;
height:100%;
width:100%;
right:-100%;
top:5px;
content:"";
border-bottom-left-radius:10px;
border-left:5px solid green;
border-bottom:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.bottom:before {
position:absolute;
height:100%;
width:100%;
left:-100%;
bottom:5px;
content:"";
border-top-right-radius:10px;
border-right:5px solid green;
border-top:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.bottom:after {
position:absolute;
height:100%;
width:100%;
right:-100%;
bottom:5px;
content:"";
border-top-left-radius:10px;
border-left:5px solid green;
border-top:5px solid green;
z-index:9999;
box-sizing:border-box;
}
<div id="content">
<div class="top colored">
</div>
<div class="left colored">
</div>
<div class="center colored">
</div>
<div class="right colored">
</div>
<div class="bottom colored">
</div>
</div>
Variation with just three divs, a bit hacky but functional. Uses pseudo elements, transforms and inner box-shadow.
div {
background-color: #000;
min-height: 100px;
}
.center {
width: 100px;
margin: 0 auto;
}
.rounded {
border-radius: 20px;
border: 5px solid red;
}
.conc {
position: relative;
}
.conc::before,
.conc::after {
content: '';
position: absolute;
border: 5px solid red;
border-radius: 20px;
width: 25px;
height: 25px;
background-color: trnaspanret;
border-color: red transparent transparent;
z-index: 3;
box-shadow: white 0px 0px 0px 20px inset
}
.conc.bottom {
margin-bottom: -5px;
border-bottom: 0;
border-radius: 20px 20px 0 0
}
.conc.top {
margin-top: -5px;
border-top: 0;
border-radius: 0 0 20px 20px
}
.conc::before {
left: -35px;
}
.conc::after {
right: -35px;
}
.conc.top::before,
.conc.top::after {
top: 0px;
}
.conc.bottom::before,
.conc.bottom::after {
bottom: 0px;
}
.conc.bottom::before {
transform: rotate(135deg)
}
.conc.bottom::after {
transform: rotate(-135deg)
}
.conc.top::before {
transform: rotate(45deg)
}
.conc.top::after {
transform: rotate(-45deg)
}
.centerblinders {
position: relative;
}
.centerblinders::before,
.centerblinders::after {
content: '';
position: absolute;
width: 130px;
height: 20px;
background-color: #000;
left: 50%;
transform: translatex(-50%);
z-index: 2;
}
.centerblinders::before {
top: -15px;
}
.centerblinders::after {
bottom: -15px;
}
<div class="rounded center conc bottom"></div>
<div class="rounded centerblinders"></div>
<div class="rounded center conc top"></div>
How to accomplish this div border using css:
I tried using dashed border but leads to this:http://jsfiddle.net/23qGr/
div {width: 20px;
height: 20px; border: 6px #6a817d dashed;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
You could use pseudo element and transparent/black borders : DEMO
div {
width: 20px;
height: 20px;
padding:6px;
position:relative;
}
div:before , div:after {
content:'';
border:6px solid transparent;
position:absolute;
}
div:before {
left:2px;
right:2px;
top:0;
bottom:0;
border-top-color:black;
border-bottom-color:black;
}
div:after {
top:2px;
bottom:2px;
left:0;
right:0;
border-right-color:black;
border-left-color:black;
}
If you increse border-width, it looks better : demo
Wondering if this is the best method to add an image to the beginning and end of my navigation. As it stands my navigation looks like this:
But realistically I would like to add this corner piece to the edges of it:
Here is my CSS of me trying to implement it:
#menu-top {
position:relative;
margin:0 -10px 0;
padding:.25em 0 0;
border-width:0;
color:#fff;
text-align:left;
background: url( http://www.leaguememe.co.uk/wp-content/uploads/2014/01/Horizontalbannermiddletop.png );
min-height:50px;
}
#menu-top:before {
content:'';
z-index: 20;
background: url( http://www.leaguememe.co.uk/wp-content/uploads/2014/01/Horizontaltop_left.png );
position:absolute;
left:0;
/* bottom:-5px; */
bottom: 0px;
width:0;
height:0;
display:block;
border-color:transparent #222 transparent transparent;
border-style:solid;
border-width:0px 10px 5px 0;
}
#menu-top:after {
content:'';
position:absolute;
right:0;
bottom:-5px;
width:0;
height:0;
display:block;
border-color:transparent transparent transparent #222;
border-style:solid;
border-width:0 0 5px 10px;
}
#menu-top ul {
position:relative;
margin:0;
padding:.5em 30px;
list-style-type:none;
text-align:center;
}
#menu-top ul:before {
content:'';
position:absolute;
top:4px;
left:-5px;
width: 34px;
height: auto;
display:block;
background: url( http://www.leaguememe.co.uk/wp-content/uploads/2014/01/Horizontaltop_left.png );
}
#menu-top ul:after {
content:'';
position:absolute;
top:4px;
right:-5px;
width:27px;
height:39px;
display:block;
}
#menu-top li {
display:inline;
margin:0 .25em 1em;
padding:0;
line-height:2.5em;
}
#menu-top li a {
background-color: #111;
color: #e9d6d6;
cursor: pointer;
display: inline-block;
font-weight: bold;
text-align: center;
line-height: 1;
outline: 0;
padding: .45em .6em;
white-space: nowrap;
-webkit-transition: background-color, -webkit-box-shadow 0.2s linear;
}
#menu-top li a:hover,
#menu-top li a:active {
text-decoration:none;
}
Am I getting the use of :Before and :After wrong?
You could do this a number of ways, including the use of pseudoelements. In the following, I placed two elements at the top left, and top right of my nav element. I then assigned the new background image, and flipped the element to the right so it mirrors that on the left:
nav {
position: relative;
width: 703px; height: 45px;
background: url("http://i.stack.imgur.com/PMV59.png");
}
nav::before, nav::after {
content: "";
display: block;
width: 95px; height: 50px;
position: absolute; top: -8px; left: -5px;
background: url("http://i.stack.imgur.com/IqsBV.png");
}
nav::after {
left: auto; right: -5px;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
Which results in the following:
I should note that the transform property was only used because you provided the left corner image only. This property is not going to be supported in Internet Explorer 8 (which does support :before and :after). If you'd like the above to support IE8, you'll need to abandon the transform, and instead provide a different background for the :after pseudoelement.
Demo: http://jsfiddle.net/NXP3g/1/
Is this possible at all using just CSS? I need to create two slant edges with an outer border but seeming that I created the slant edges with a border I am completely lost.
This is how far I got.
JSFIDDLE does not seem to want to load today??? but will post it on there as soon as possible :).
Here's the CSS:
.wrap {width:29%;}
.slider-header:before {
content:'';
border-top:20px solid white;
border-right: 20px solid #000;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height:20px;
position: absolute;
top: 0;
left: 0;
height:100%;
width: 20px;
}
.slider-header {
color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
background:#000000;
position:relative;
font-size:1em;
padding-left:1.5em;
width:200px;
float:right;
}
.slider-header2:before {
content:'';
border-bottom:20px solid white;
border-left: 20px solid #000;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height:20px;
position: absolute;
top: 0;
right: 0;
height:100%;
width: 20px;
}
.slider-header2 {
color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
background:#000000;
position:relative;
font-size:1em;
padding-left:1.5em;
width:200px;
float:left;
}
and the HTML:
<div class="wrap">
<div class="slider-header">
hey2
</div>
<div class="slider-header2">
hey
</div>
<div>
Hey everyone answers has been great especially Aequanox but i need this to work on IE8+ and if its IE7+ ill probably name my first born after you..
Here is achieved without adding any markup.
<div class="wrap">
<div class="slider-header">
hey1
</div>
<div class="slider-header2">
hey2
</div>
<div>
CSS is not optimized at all, just to achieve the deired effect.
.wrap{width:500px; padding:5px; display:block; overflow:hidden}
.wrap div{background:#333; color:#fff; width:235px; }
.wrap:after{
content:"";
display:block;
border-top:1px solid #333;
margin-top:-5px;
margin-left:265px;
width:235px;
}
.wrap:before{
content:"";
display:block;
border-bottom:1px solid #333;
position:absolute;
top:37px;
width:235px;
}
.slider-header{position:relative; float:left;}
.slider-header2{position:relative; float:right;}
.slider-header:before{
content:"";
display:block;
height:1px;
width:70px;
background:#333;
position:absolute;
left:225px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
}
.slider-header:after{
content:"";
display:block;
width:0;
height:0;
position:absolute;
top:0;
right:-20px;
border-right: 20px solid transparent;
border-top: 20px solid #333;
}
.slider-header2:before{
content:"";
display:block;
width:0;
height:0;
position:absolute;
top:0;
left:-20px;
border-left: 20px solid transparent;
border-bottom: 20px solid #333;
}
And here's the fiddle : http://jsfiddle.net/dG7mD/
It is possible to draw the shapes:
http://techcruser.blogspot.com/2011/08/draw-various-shapes-using-css.html
I was able to get the shapes without writing in them:
html:
<table>
<tr>
<td class="triangle-topleft">
button1
</td>
<td class="triangle-bottomright">
button2
</td>
</tr>
</table>
css:
.triangle-topleft {
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
*/}
.triangle-bottomright {
width: 0;
height: 0;
border-bottom: 100px solid red;
border-left: 100px solid transparent;
}
but honestly, I would use jquery to do my buttons or menus. It makes it easier in the long run.
What about using some simple hr's?
HTML:
<div id="elem"> <span>Text 1</span>
<span>Text 2</span>
<hr id="hr1" class="lines" />
<hr id="hr2" class="lines" />
<hr id="hr3" class="lines" />
</div>
CSS:
#elem {
height: 50px;
width: 320px;
background: black;
margin: 50px;
position: relative;
}
#elem > span {
box-sizing: border-box;
height: 100%;
width: 50%;
color: white;
display: block;
float: left;
padding: 0.2em 1.5em;
}
hr.lines {
height: 1px;
background-color: black;
color: black;
border: 3px solid white;
border-left: 0 none;
border-right: 0 none;
position: absolute;
margin: 0;
}
hr#hr1 {
-webkit-transform: rotate(-55deg);
-moz-transform: rotate(-55deg);
-o-transform: rotate(-55deg);
width: 70px;
top: 50%;
left: 50%;
margin-left: -40px;
margin-top: -3px;
}
hr#hr2 {
width: -webkit-calc(50% - 25px);
bottom: -7px;
left: 0;
}
hr#hr3 {
width: -webkit-calc(50% - 15px);
top: -7px;
right: 0;
}
Fiddle!