我条目旁边的按钮始终显示在条目下方

时间:2019-05-29 03:51:54

标签: html css

我有一个正在建立条目的博客。我有一个带有隐藏变量的表单,用于提交entryID和其他数据以“删除”该帖子。该按钮始终显示在条目下方,而不是在条目旁边。

我尝试使用CSS Clear,并将所有内容放在单个<p>行中,以查看是否有帮助。我觉得问题在于存在一个带有隐藏变量的表单,但是我不确定如何解决此问题。

 <div id="subformposts">
    <?php echo $subentry['Body']; ?>
    <?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />

<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">     
        <input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
        <input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
        <?php if ($userid == 1 || $userid == $res['UserID']) { ?>
        <input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
    <?php } ?>
</form>
</div>

我想看到按钮浮动在我输入的右边(或此时在左边)。如果我可以把它塞进div,那就太好了。

1 个答案:

答案 0 :(得分:2)

您可以在display: inline-flex上使用subformposts

喜欢这个:

<div id="subformposts" style="display: inline-flex;">
<?php echo $subentry['Body']; ?>
<?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />

<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo 
$subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">     
    <input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
    <input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
    <?php if ($userid == 1 || $userid == $res['UserID']) { ?>
    <input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>

或者您可以将两者都保留在两个不同的div中,并将display:inline-block放在这两个div上。像这样 。

 <div id="subformposts" style="display: inline-block;">
 <?php echo $subentry['Body']; ?>
 <?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />
</div>
<div style="display: inline-block;">
<!-- Determine whether to show the delete button -->
 <form action="Delete_entry.php" method="post" id="Deletesub<?php echo 
 $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">     
<input type="hidden" readonly="true" name="EntryID" value="<?php echo 
$subentry['EntryID']; ?>" />
<input type="hidden" readonly="true" name="UserID" value="<?php echo 
$subentry['UserID']; ?>" />
<?php if ($userid == 1 || $userid == $res['UserID']) { ?>
<input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>