我有以下页面:
我正在使用绝对定位将我的内容放在图像旁边.不确定这是否可以使用内联块或浮点数,这将解决我的问题.
我现在的问题是页脚与我的内容重叠,因为绝对定位的内容会失去它的高度.
JSFiddle:https://jsfiddle.net/sc3e1t15/
.wrapper { position: relative; }
.title,
.footer { font-weight: bold; }
.image { font-style: italic; width: 210px; border: 1px solid red; }
.links { max-width: 210px; }
.content { position: absolute; top: 18px; left: 220px; border: 1px solid green; }Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="title">
I'm the title.
</div>
<div class="image">
I'm an image.
</div>
<div class="links">
I'm some links.<br>
I want to be on the left side too!
</div>
<div class="content">
I'm the content.<br>
I want to be shown neatly next to the image.<br>
Spread over multiple lines<br>
Nothing to see here<br>
Staph reading me!<br>
Love you brah.
</div>
<div class="footer">
I'm a problem ... Because I disrespect the contents height.
</div>
</div>Run Code Online (Sandbox Code Playgroud)
试试这个.在左侧包含您想要的内容并为其显示属性.
{display:inline-block;}
这里不需要使用位置.
.wrapper { position: relative; }
.title,
.footer { font-weight: bold; }
.image { font-style: italic; width: 210px; border: 1px solid red; }
.links { max-width: 210px; }
.content { display:inline-block; border: 1px solid green; }
.left-contain { display: inline-block; vertical-align: top;}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="title">
I'm the title.
</div>
<div class="left-contain">
<div class="image">
I'm an image.
</div>
<div class="links">
I'm some links.<br>
I want to be on the left side too!
</div>
</div>
<div class="content">
I'm the content.<br>
I want to be shown neatly next to the image.<br>
Spread over multiple lines<br>
Nothing to see here<br>
Staph reading me!<br>
Love you brah.
</div>
<div class="footer">
I'm a problem ... Because I disrespect the contents height.
</div>
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |