I want to specify all properties ( top,right,bottom,left ) in one single line of CSS like how we are specifies margin:50px; ( margin-top:50px,margin-right:50px,margin-bottom:50px,margin-left:50px )
Is there any way to do this?
Thank you
I want to specify all properties ( top,right,bottom,left ) in one single line of CSS like how we are specifies margin:50px; ( margin-top:50px,margin-right:50px,margin-bottom:50px,margin-left:50px )
Is there any way to do this?
Thank you
yeah the correct way is like so. It goes Top right bottom left.
margin: 10px 20px 50px 30px;
so its
margin: top right bottom left;
Ok so I am not to sure what you are asking. Still.
So I will try my best.
Margin works like so. There is 4 sides as you stated, top right bottom left, a clock wise motion.
You can target each one like I have done above OR if they are all the same you can do this
margin: 20px;
however if the left and right are the same and so is the top and bottom you can do this
margin: 20px 30px;
eg i use
margin: 0 auto;
all the time
You can also do
margin: 20px 30px 10px;
which will target the top with 20px the right with 30px the bottom with 10px and the left with 30px
If you only want the right you can do this
margin-right: 20px;
the same goes for margin-top, margin-bottom, margin-left.
The easiest way to do it is by using the inset
property.
For instance, both
top: 5px;
bottom: 10px;
left: 8px;
right: 8px;
and
inset: 5px 8px 10px 8px;
do the same thing.
You can find deeper information & examples here: https://developer.mozilla.org/en-US/docs/Web/CSS/inset
So you're asking how to specify margin-top
, margin-left
, margin-bottom
and margin-right
on one line?
Easy:
You can use for example. margin: 25px 50px 75px 100px;
. This will result in the same as:
margin-top: 25px;
margin-right: 50px;
margin-bottom: 75px;
margin-left: 100px;
The same applies to the padding
property.
See more http://devdocs.io/css/margin and http://devdocs.io/css/padding
You can use inset
like this:
inset: 5px 3px 1px 10px;
The order is top
, right
, bottom
, left
There is many options for value assign in on line:
margin:10px;
margin:10px 20px 30px 40px
(top, right, bottom, left)margin: 10px 30px;
(top-bottom, left-right).Same as all you can use in padding as well.