How to position a heading in one corner and a button on the opposite corner

Viewed 150

Expected: I am trying to get the same as in the following image. 'Finding Nemo' heading on one side and 'Watch Video' button on other side

Actual: But what I got is as in the following image 'Finding Nemo' heading and 'watch Video' button both on side by side

Here's my HTML:

<div class="heading-container d-flex flex-row justify-content-start">
    <h1 class="main-heading"> Finding Nemo </h1>
    <button class="button"> Watch Now </button>
</div>

And CSS:

.heading-container {
    margin-top: 20px;
}

.main-heading {
    color: #ffffff;
    font-family: "Roboto";
    font-size: 24px;
    font-weight: bold;
}

.button {
    background-color: #ffffff;
    color: #ff8348;
    border-width: 0px;
    border-radius: 10px;
    height: 32px;
    width: 110px;
    font-size: 13px;
}
2 Answers

I see you're using bootstrap, you can just add align-right to the class of your button:

<button class="button float-right"> Watch Now </button>

Can you please check the below code? Hope it will work for you. You just need to replace justify-content-start with justify-content-between bootstrap class in heading-container. It will display the child items with space between the lines.

<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="heading-container d-flex flex-row justify-content-between">
    <h1 class="main-heading"> Finding Nemo </h1>
    <button class="button"> Watch Now </button>
</div>

Related