css - Get a blank line after div by simply leaving an empty line in the editor

I'm styling a div object so that its content behaves like a normal text.As first thing I set its line height as the

I'm styling a div object so that its content behaves like a normal text.

As first thing I set its line height as the default line-height of a line in a paragraph.

I got this by adding the following css code

.myclass div {
    margin: -1.43em 0 -0.93em 0;
}

In this way, by writing this in the WP editor

badp
<div class=myclass>badp</div>
badp

the vertical spacing is changed as shown in the image


Next I'd like that an empty line after the div in the editor will correspond to a blank line in the webpage. That is, I'd like that by writing

badp
<div class=myclass>badp</div>

badp

the vertical spacing will be changed as shown in the image

I know that this can be obtained by inserting &nbsp; in the empty line, but is it possibile to achieve it by simply leaving an empty line as we usually do for normal text?

I'm styling a div object so that its content behaves like a normal text.

As first thing I set its line height as the default line-height of a line in a paragraph.

I got this by adding the following css code

.myclass div {
    margin: -1.43em 0 -0.93em 0;
}

In this way, by writing this in the WP editor

badp
<div class=myclass>badp</div>
badp

the vertical spacing is changed as shown in the image


Next I'd like that an empty line after the div in the editor will correspond to a blank line in the webpage. That is, I'd like that by writing

badp
<div class=myclass>badp</div>

badp

the vertical spacing will be changed as shown in the image

I know that this can be obtained by inserting &nbsp; in the empty line, but is it possibile to achieve it by simply leaving an empty line as we usually do for normal text?

Share Improve this question asked Sep 12, 2019 at 16:17 sound wavesound wave 2151 gold badge3 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

A solution is to create a new class, say extra-space, with css margin-bottom: 0.5em and write

<div class="myclass extra-space">...text...</div>

when the div need more space.

Important: the class extra-space has to be placed AFTER the other class in the style.css file, otherwise the extra space will not be added.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745162955a4614480.html

相关推荐

  • css - Get a blank line after div by simply leaving an empty line in the editor

    I'm styling a div object so that its content behaves like a normal text.As first thing I set its line height as the

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信