Skew div border of one side using only one div

I created a skewed div using the following css

#outer-left{
-ms-transform: skew(-30deg,0deg); /* IE 9 */
-webkit-transform:skew(-30deg,0deg); /* Chrome, Safari, Opera */
transform: skew(-30deg,0deg);
background:#333333;
width:200px;
z-index:20;
border-bottom:3px solid #2E8DEF;
padding:10px 30px 10px 75px;
font-size:20px;
color:#2E8DEF;
position:relative;
left:-50px;
}
#outer-left:after{
content:"";
display:inline-block;
position:absolute;
width:20px;
height:100%;
background:#2E8DEF;
float:right;
right:0px;
top:0px;
z-index:10;
}

#inner-left{
-ms-transform: skew(30deg,0deg); /* IE 9 */
-webkit-transform: skew(30deg,0deg); /* Chrome, Safari, Opera */
transform: skew(30deg,0deg);
display:inline-block;
}

And used two divs, i.e. the outer div, to skew the border and the div and the inner div to cancel the skew effect for the text.

enter image description here

But I achieved the same effect using only one div in div3

Look at the fiddle: http://jsfiddle.net/5a7rhh0L/

IF I do the same as in div 3, with a lot of text that it distorts. But not so in the case of div2 with lots of text using 2 divs.

I fully understand what is happening here. I want to know if DIV2 can be achieved using only one div ie <div id="inner-div">Context<br>Hello</div>and now without using two divs, i.e. internal and external.

+4
1

, , :

http://jsfiddle.net/5a7rhh0L/3/

CSS

#a {
    position: relative;
    width: 120px;
    padding: 10px 20px;
    font-size: 20px;
    position: relative;

    color: #2E8DEF;
    background: #333333;
    border-bottom: 3px solid #2E8DEF;
}
#a:after {
    content: " ";
    position: absolute;
    display: block;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: -1;

    background: #333333;
    border-bottom: 3px solid #2E8DEF;
    border-right: 20px solid #2E8DEF;

    transform-origin: bottom left;
    -ms-transform: skew(-30deg, 0deg);
    -webkit-transform: skew(-30deg, 0deg);
    transform: skew(-30deg, 0deg);
}
+14

All Articles