简体   繁体   English

外部DIV中的居中2 DIV与文本对齐的中心+显示行内块

[英]Center 2 DIV within outer DIV with text-align center + display inline-block

I followed a Q&A from other thread to center 2 DIV which is inside a div but not solve. 我从另一个线程到位于div内的中心2 DIV进行了问答,但没有解决。 I added text-align center to outer DIV and display inline-block to both left and right DIV. 我在外部DIV中添加了文本对齐中心,并在左右DIV中显示了内联块。 Pls try to let me know what is lacking... Here is jsfiddle 请尝试让我知道缺少什么... 这是jsfiddle

HTML: HTML:

<div class="indexDiv" id="noPad">
<div class="results">
<div id="topResults">Top</div>
<div id="refineResults">Left</div>
<div id="listingsResults">Right</div>
</div>    
</div>

CSS: CSS:

.indexDiv {
overflow: hidden;
width: 993px;
background: #ffffff;
margin: 0 auto;
padding: 10px;
}

.Results {
color: #D5241B;
font-size: 20px; font-weight: bold;
/*    margin: 4px 0 8px;*/
border: 1px solid #D9D9D9;
}

.Results {
/*  padding: 10px;*/
text-align: center;
width: 930px;
margin:0 auto;
}

#topResults {
float: right;
width: 100%;
margin: 0 0 10px 0;
border: 1px solid #D9D9D9;
}

#refineResults {
/*  float: left;*/
width: 200px;     
display: inline-block;    
/*  padding: 5px; */
border: 1px solid #D9D9D9;
}

#listingsResults {
/*  float: right;*/
width: 715px;
/*  margin-left:18px;*/
border: 1px solid #D9D9D9;
display: inline-block;    
/*   padding: 5px; */
}

CSS class selectors are case-sensitive. CSS类选择器区分大小写。 You have .Results , which doesn't select your element with class = "results" . 您有.Results ,它不会选择class = "results"元素。 Replace it with .results ; 将其替换为.results ; here's a fixed demo: little link . 这是一个固定的演示: 小链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM