如何修复 col-lg-8 中的按钮元素?
How can I fixed element a button in col-lg-8?
我想要它,就像我在下面的图片中分享的那样,但我无法设置它。我正在分享我在下面写的代码。我该如何解决这个问题?
我的代码:
#mybtn{
position: fixed;
bottom: 10px;
right: 10px;
}
<div class="row">
<div class="col-lg-8" style="position: relative;">
<p>this is my content</p>
<button id="mybtn">My Fixed Button</button>
</div>
<div class="col-lg-4">
<p>content area</p>
</div>
</div>
您可以将 button
包裹在 div
中,然后在 div
上使用 d-flex justify-content-end
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="row">
<div class="col-lg-8 bg-danger">
<p>this is my content</p>
<div class='w-100 d-flex justify-content-end'>
<button id="mybtn" class='btn btn-primary btn-sm'>Button</button>
</div>
</div>
<div class="col-lg-4">
<p>content area</p>
</div>
</div>
我想要它,就像我在下面的图片中分享的那样,但我无法设置它。我正在分享我在下面写的代码。我该如何解决这个问题?
我的代码:
#mybtn{
position: fixed;
bottom: 10px;
right: 10px;
}
<div class="row">
<div class="col-lg-8" style="position: relative;">
<p>this is my content</p>
<button id="mybtn">My Fixed Button</button>
</div>
<div class="col-lg-4">
<p>content area</p>
</div>
</div>
您可以将 button
包裹在 div
中,然后在 div
d-flex justify-content-end
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="row">
<div class="col-lg-8 bg-danger">
<p>this is my content</p>
<div class='w-100 d-flex justify-content-end'>
<button id="mybtn" class='btn btn-primary btn-sm'>Button</button>
</div>
</div>
<div class="col-lg-4">
<p>content area</p>
</div>
</div>