2013-12-19 22 views
-1

'2em 10px'在css屬性值中的含義是什麼?瞭解css值:2em 10px

實施例:margin: 1em 40px;

+0

這取決於屬性。可以在CSS規範和草稿中的屬性定義中找到答案。 –

回答

2

1em的是用於頂部和底部邊緣

40像素爲左右邊距

1EM等於當前字體大小

它也可以被寫像

margin-top: 1em; 
margin-right: 40px; 
margin-bottom: 1em; 
margin-left: 40px; 

或類似

margin: 1em 40px 1em 40px; 

甚至另一種方式,所以如果當前字體大小爲24像素,則保證金將是相同

margin: 24px 40px; 

,但可以說,計算機用戶會放大他們的屏幕200%的再保證金將

margin: 48px 40px; 
3

利潤率接受一到四個參數:

One single value applies to all four sides. 
Two values apply first to top and bottom, the second one to left and right. 
Three values apply first to top, second to left and right and third to bottom. 
Four values apply to top, right, bottom and left in that order (clockwise). 

,你可以在這裏閱讀詳細

https://developer.mozilla.org/en-US/docs/Web/CSS/margin

0

W3 Org,單位的定義, 「EM」 被定義爲

"The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion. Declarations such as 'text-indent: 1.5em' and 'margin: 1em' are extremely common in CSS. " 

而 「PX」 被定義爲:

"The px unit is the magic unit of CSS. It is not related to the current font and also not related to the absolute units. The px unit is defined to be small but visible, and such that a horizontal 1px wide line can be displayed with sharp edges (no anti-aliasing). What is sharp, small and visible depends on the device and the way it is used: do you hold it close to your eyes, like a mobile phone, at arms length, like a computer monitor, or somewhere in between, like a book? The px is thus not defined as a constant length, but as something that depends on the type of device and its typical use. "**strong text**