css 识别变量中的换行符,使用CSS时的换行符“display:inline”

I have successfully managed to get a

follow a on the same line, however I wish to repeat this on a new line, but the next is following on from the last

- what should I do?

I have tried various "clear" options, but none break the inline. I don't really want to use
or have an empty

, not overly happy to surround with

either.

Note - I have tried removing the inline from the second element, and while that does place the on a new line, the following

ends up on it's own new line too.

CSS

.inline {display: inline;}

.newline {clear: left;}

HTML

Heading:

Some text.

Next Heading:

Some more text.

This is the result I want to achieve:

Heading: Some text.

Next Heading Some more text.

but instead I am getting this:

Heading: Some text. Next Heading Some more text.

Any suggestions - trying to keep the code as simple and neat as possible.

[Update]

For the time being I am going to add an empty div as suggested by hafid2com, using the following (just adding height to achieve the desired result):

.clear { clear: both; display: block; content: ""; width: 100%; }

解决方案

Add this:

HTML:

Heading:

Some text.

Next Heading:

Some more text.

CSS:

.inline {display: inline;}

.clear{

clear: both;

display: block;

content: "";

width: 100%;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值