1

如何在 midItem 元素周围设置适当的边框?

http://jsfiddle.net/PmfLm/

这是同一个小提琴的缩小代码,

<!DOCTYPE html>
<meta charset="utf-8"> 
<html>
<head>
    <style type="text/css">
    span,.midItem {
        border-style: solid;
    }
    .midItem {
        border-color: blue;
        padding: 5px;
    }
    p {
        text-align:justify;     
    }
    .leftPage,.rightPage{
        display:inline-block;
        width: 33%;
        padding: 5px;
    }
    .centerBox {
        display:table-cell;
        text-align: center;
        vertical-align: middle;
    }
    .leftBox,.rightBox {
        display: table;
        border-style:dotted; 
        border-width:5px;
        width: 100px;
        height: 100px;
        border-color:green;
    }
    .leftBox,.leftPage {
        float:left; 
    }
    .rightBox,.rightPage {
        float:right; 
    }
    </style>
</head>
<body>
<span class="leftPage"><span class="leftBox"><p class="centerBox">Leftbox</p></span>
<p>Some Text</p>
</span>
<span class="rightPage"><span class="rightBox"><p class="centerBox">rightBox</p></span>
<p>SomeText</p>
</span>
<p class="midItem">SomeText</p>
</body>
</html>
4

2 回答 2

2

没有正确回答你的问题,但你需要这样的东西吗?如果是,则清除浮动,overflow: hidden;用于容器 div

演示

CSS

span,.midItem {
    border-style: solid;
    overflow: hidden;
}
于 2012-11-29T12:35:58.790 回答
1

如果您使用 table-cell 在所有元素中获得相同的高度,那么您应该将其设置为所有三个元素

.midItem {
    border-color: blue;
    padding: 5px;
    display:table-cell;
}
.leftBox,.leftPage {
    display:table-cell;
}
.rightBox,.rightPage {
    display:table-cell;
}

http://jsfiddle.net/PmfLm/3/

于 2012-11-29T12:43:38.833 回答