So I'm trying to display my button more to the right. However, no matter what I try, I can't get it to move it beyond only a few positions. To generalize the million things I've been attempting and the outputs, the button displayed is always either:
when I have the opening tag,
<div className="container">
, the button is pretty far on left sideOr if I try as my opening tag as just
<div>
or<div className="btn-top-right">
, the button is completely on the left sideThe button here is positioned on the right, but a little too far for me. (https://i.stack.imgur.com/7dvJb.png)
Here's my current javascript/html + CSS:
<div className="container">
<button className="btn btn-primary btn-top-right float-end">CPU</button>
</div>
where I also tried <div>
and <div className="btn-top-right
> for the opening tag in the above^ code snippet.
.btn-top-right {
position: absolute;
top: 20px;
right: 50px;
}
.btn-top-right {
position: absolute;
top: 20px;
right: 50px;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<div class="container">
<button class="btn btn-primary btn-top-right float-end">CPU</button>
</div>
As you can see above, right is set to 50px, but no matter what value I try, it won't move. Any thoughts?
You might have to account for built-in bootstrap styles on the container.
Here are two examples of two different container types and how I used the padding on the
container-fluid
for example to put the padding to 0 usingps-0
then put a margin on the button to move it from the left. Might need some specifics but as the first example shows be careful of the position since it might get outside of the container which may not be the desired behavior.