Reputation: 61
I am using 3 boxes with text content where next t the the last box, some text is being displayed instead of leaving a blank and appear under.
See attached screenshot:
.box_question {
float: left;
margin: 10px;
padding: 10px;
max-width: 300px;
border: 1px solid black;
padding-bottom: 1%;
}
<div class="box_question">
<p class="sub-heading"> text </p>
</div>
float: right; does the samething but to the left... float:center; works but doesn't not display all 3 boxes next to each others... I am not quite sure what to put between the last box and the next text. Please help me.
Upvotes: 3
Views: 72
Reputation: 4938
Firstly you must insert the boxes in one single div
which will acts as a row.
i have used class: question_row
Then add some CSS to its after
and before
elements as follows:
.box_question {
float: left;
margin: 10px;
padding: 10px;
width: 300px;
border: 1px solid black;
padding-bottom: 1%;
display: inline-block;
margin-left:calc(50% - 150px);
}
p {
float: left;
width: 100%;
}
.question_row::before,
.question_row::after {
display: table;
content: ' ';
clear: both;
}
<p class="sub-heading"><span style="color: #000000;">Examples of Lorem Ipsum is simply dummy :</span>
</p>
<div class='question_row'>
<div class="box_question">
<p class="sub-heading">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.!</p>
</div>
<div class="box_question">
<p class="sub-heading">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever sinn an unknown printer took a galley of type and scrambled it to make a type specimen book. Itleap 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.
</p>
</div>
<div class="box_question">
<p class="sub-heading">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. release
of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
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.
<br />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.
EDIT: Added margin-left
to .box_question
in snippet
Upvotes: 2
Reputation: 784
<div></div>
tag.Tip: If it is a responsive design consider using units like em
, rem
or %
instead of px
.
.box_question {
margin: 10px;
padding: 10px;
width: 300px;
border: 1px solid black;
padding-bottom: 1%;
display: inline-block;
}
<p class="sub-heading">
<span style="color: #000000;">Examples of Lorem Ipsum is simply dummy :</span>
</p>
<div class="box_question">
<p class="sub-heading">Box1</p>
</div>
<div class="box_question">
<p class="sub-heading">Box2</p>
</div>
<div class="box_question">
<p class="sub-heading">Box3</p>
</div>
<div>
Large text goes here which is below the boxes always...
</div>
Upvotes: 1
Reputation: 330
try this, i think it will solve the problem
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#boxblock{
width: 100%;
clear: both;
display: block;
}
.box_question {
float: left;
margin: 10px;
padding: 10px;
max-width: 300px;
border: 1px solid black;
padding-bottom: 1%;
}
.sub-heading{
clear: both;
display: block;
}
</style>
</head>
<body>
<div id="boxblock">
<div class="box_question">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at ante. Mauris eleifend, quam a vulputate dictum, massa quam dapibus leo, eget vulputate orci purus ut lorem. In fringilla mi in ligula. Pellentesque aliquam quam vel dolor. Nunc adipiscing. Sed quam odio, tempus ac, aliquam molestie, varius ac, tellus. Vestibulum ut nulla aliquam risus rutrum interdum. Pellentesque lorem. Curabitur sit amet erat quis risus feugiat viverra. Pellentesque augue justo, sagittis et, lacinia at, venenatis non, arcu. Nunc nec libero. In cursus dictum risus. Etiam tristique nisl a nulla. Ut a orci. Curabitur dolor nunc, egestas at, accumsan at, malesuada nec, magna
</div>
<div class="box_question">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at ante. Mauris eleifend, quam a vulputate dictum, massa quam dapibus leo, eget vulputate orci purus ut lorem. In fringilla mi in ligula. Pellentesque aliquam quam vel dolor. Nunc adipiscing. Sed quam odio, tempus ac, aliquam molestie, varius ac, tellus. Vestibulum ut nulla aliquam risus rutrum interdum. Pellentesque lorem.
</div>
<div class="box_question">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at ante. Mauris eleifend, quam a vulputate dictum, massa quam dapibus leo, eget vulputate orci purus ut lorem. In fringilla mi in ligula. Pellentesque
</div>
</div>
<div class="sub-heading">
<p> text </p>
</div>
</body>
</html>
Upvotes: 1
Reputation: 8409
add this text in a p
tag and css like
p {
float:left;
width:100%;
}
here is the fiddle
Upvotes: 3