Home > Web Front-end > HTML Tutorial > css 如何让浮动DIV水平居中

css 如何让浮动DIV水平居中

WBOY
Release: 2016-06-01 09:53:25
Original
1676 people have browsed it

实例如下:

<code class="language-html">

<meta charset="UTF-8">
<title>css3对话框设计</title>
<style>
.box{
    float:left;
    position:relative;
    left:50%;
}
p{
    float:left;
    position:relative;
    right:50%;
}
</style>


<div class="box">
    <p>我是浮动的</p>
    <p>我也是居中的</p>
</div>

</code>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template