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

css 如何让浮动DIV水平居中

WBOY
WBOYOriginal
2016-06-01 09:53:251585browse

实例如下:

<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>

 

Statement:
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