I’m working on a project using Bootstrap as my front end framework.
I’ve got a vertical scrollable card with some items in it. Each row is composed of the following code:
<p>
<span>
<span style="display: inline-block; width: 100px;">
<strong><?php echo $clientSiteDemandRow['dayOfWeek']; ?></strong>
</span><span style="display: inline-block; width: 70px;">
<i class="fa fa-clock"></i> <?php echo $clientSiteDemandRow['shiftStart']; ?>
</span>
<span style="display: inline-block; width: 100px;">
<?php echo $hours; ?> Hours
</span>
<span style="display: inline-block; width: 30px;" style="white-space: nowrap;">
<form action="" method="POST">
<button type="submit" class="btn btn-danger btn-sm" id="deleteSiteDemand" name="deleteSiteDemand" value="<?php echo $clientSiteDemandRow['id']; ?>">Delete</button>
</form>
</span>
</span>
</p>
As you can see the first row renders how I want it, but on the subsequent rows the ‘Delete’ button wraps to the next line. It’s not a space issue as there is plenty of room for the button.
How can I keep that button on the same row? All my google searches result in inline forms and not necessarily my situation.
I have tried these:
How to force button and select on the same line?
I have tried using display: inline; and display: inline-block; on the outermost span to no effect.
3
Answers
Try:
Looks like a table
First of all don’t wrap your elements in a
p
tag, usediv
.id
should be unique. All your Delete buttons have sameid
NB: For your scenario I would just using Bootstrap grid layout.
Looking at your code, try removing the wrapping
p
tag with adiv
form
inside ap
is not semantically correct even though it works in most cases. In some scenarios it behave weird . As per spec only phrasing contents are allowed inside ap
tag.