Can anyone suggest a better way of using dividers one shorter and one longer 2px solid at the center of page after a section or paragraph. I do not want to repeat myself using like the following
<section>
<article>
<p>texttext text </p>
<div id="divider">
<div id="divider-short"> </div>
<div id="divider-long"> </div>
</div>
</article>
</section>
#divider{
float:right;
margin-right:35%
direction:rtl;
}
#divider-short{
width:150px;
border:2px solid gray;
margin-top:30px;
clear:both;
}
#divider-long{
margin-top:10px;
width:300px;
border:2px solid gray;
clear:both;
}
CodePudding user response:
you can create one common divider class and add it where you want divider.
.divider{
padding-bottom:25px;
position:relative;
}
.divider:before,.divider:after{
width:300px;
height:2px;
background-color:red;
display:inline-block;
content:"";
position:absolute;
bottom:8px;
margin-left:auto;
margin-right:auto;
left:0;
right:0;
}
.divider:before{
width:200px;
bottom:14px;
}
<section >Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</section>
<section >Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</section>
<section >Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</section>
CodePudding user response:
I would remove the divider HTML and use this CSS (adjust colors, spacing, etc):
article {
position: relative;
padding-bottom: 30px;
}
article:before {
content: '';
position: absolute;
width: 100px;
background: grey;
left: 50%;
transform: translateX(-50%);
height: 4px;
bottom: 20px;
}
article:after {
content: '';
position: absolute;
width: 200px;
background: grey;
left: 50%;
transform: translateX(-50%);
height: 4px;
bottom: 10px;
}
CodePudding user response:
I suggest you to use <hr/>
tag that is dedicated for a breaker.
For example you can do the following to do two line break of multiple length
<hr style='width:25%'/>
<hr style='width:60%'/>
This is just an example, you can stylize hr the same way as other tags