display elements of attribute type box should generate rules.
display of more of the description
Here the main focus display:block;
and display:inline-block
, well width
, height
, margin
, padding
expand
The basic code is as follows
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
margin: 0;
}
.block {
background: red;
}
.inline {
background: yellow;
}
.block,
.inline {
width: 200px;
height: 50px;
margin: 10px;
padding: 10px;
}
</style>
</head>
<script>
</script>
<body>
<div class="block">
display:block
</div>
<div class="block">
display:block
</div>
<span class="inline">
display:inline
</span>
<span class="inline">
display:inline
</span>
</body>
</html>
复制代码
Html and css standards of proficiency => see conceivable interface style code
The above code as better than the blunt face questions asked: "display: block; and display: inline; what difference"
div
Tag, block-level elements, the display attribute is the default block
, span
the label, the line elements, the display attribute defaultsinline
Label refers to the HTML element refers to the browser
Class packet selector and the selector
.block
Selector is a class, except that in front of the symbol .
, the label may be used by a class attribute.
.block, .inline a packet selector, except that the front of the symbol ,
, expressed .block
and .inline
shared style
Can be viewed through the Developer Tools
width
, height
, margin
, padding
Different appearances
div
And span
useful for the same width
, height
, margin
,padding
However , span
the width
, height
it is a complete failure.
margin
Only horizontal work
Orange represents margin
, green representspadding
And padding
the span
representation is different from div
the
Write temporary inline styles for elements with developer tools
Developer Tools can element.style
try as equivalent to write an inline style on the label
Enter p
after the prompt, it comes with its own filtering. Can be selected by the vertical direction keys of the keyboard, blue background represents the currently selected, pressing the tab key rapid filling property, then enter 100px
The vertical direction can be adjusted by the size of the key attribute value, while holding down the ctrl
amplitude is 100, while holding shift
an amplitude of 10, while holding down the alt
amplitude 0.1
100px and padding can click again to completely remove any will delete the entire statement.
The same change in role div
for the
About padding
to see www.w3school.com.cn/cssref/pr_p...
Egg
<div style="text-align: center">
<span class="inline" style="padding:10px">
display:inline;
</span>
</div>
复制代码
Developer Tools by changing padding
the value of
The last chapter - 3 document.body Why is null
Next chapter - border attribute in 5 css