<div class= "Main" >
</div>
<style>
. Main
{
width:500px;
height:600px;
BORDER:1PX solid black;
Display:table-cell;
Vertical-align:middle;
Text-align:center;
}
</style>
Get!
2: Background law:
<style>
. Main
{
width:500px;
height:600px;
BORDER:1PX solid black;
Display:table-cell;
Vertical-align:middle;
Text-align:center;
Background:url (' 3.jpg ') center no-repeat;
}
</style>
<body>
<div class= "Main" >
<!---->
</div>
</body>
Here again, the text is centered vertically and automatically wraps the settings, on the code:
<style>
. Main
{
width:500px;
height:300px;
BORDER:1PX solid black;
Display:table-cell;
Vertical-align:middle;
Text-align:center;
word-wrap:break-word;//Text Wrap
white-space:nowrap;//This sentence means never wrap, even if the parent container has a fixed width, it will also hold the parent container large, in a row display
}
</style>
<body>
<div class= "Main" >
h haha haha haha haha switch on the examination room is preoccupied ha haha haha haha very tangled Army Day Army Day Army Day Army Day Army Day Army Day Army Day Army Day Acceleration Gastrointestinal Division
</div>
</body>
Questions about vertical centering of images with unknown size