I have following code
div {
width:200px;
border-bottom:1px solid magenta;
height:50px;
}
The div width is 200px so border-bottom is also 200px but what should I do if I want border-bottom only 100px without changing div width?
I have following code
div {
width:200px;
border-bottom:1px solid magenta;
height:50px;
}
The div width is 200px so border-bottom is also 200px but what should I do if I want border-bottom only 100px without changing div width?
Late to the party but for anyone who wants to make 2 borders (on the bottom and right in my case) you can use the technique in the accepted answer and add an :after psuedo-element for the second line then just change the properties like so: http://jsfiddle.net/oeaL9fsm/
You can use pseudoelements. E.g.
No need to use extra markup for presentational purpose. :after is also supported from IE8.
edit:
if you need a right-aligned border, just change
left: 0
withright: 0
if you need a center-aligned border just simply set
left: 50px;
You can use a linear gradient:
I have case to have some bottom border between pictures in div container and the best one line code was - border-bottom-style: inset;
I just accomplished the opposite of this using
:after
and::after
because I needed to make my bottom border exactly1.3rem
wider:My element got super deformed when I used
:before
and:after
at the same time because the elements are horizontally aligned withdisplay: flex
,flex-direction: row
andalign-items: center
.You could use this for making something wider or narrower, or probably any mathematical dimension mods:
Sorry, this is
SCSS
, just multiply the numbers by 10 and change the variables with some normal values.