What steps do I need to take to create this specific header design?

I've been working on implementing this unique header design using Bootstrap.

https://i.sstatic.net/1zFCw.jpg

Even though I tried utilizing the grid system, it doesn't seem like the ideal approach. The code I currently have doesn't position the two buttons correctly in the lower right corner.

Here is the HTML code snippet:

<div class="row">
  <div class="col-sm-12 mb-3">
    <div class="line"></div>
    <div class="row">
      <div class="col-sm-3 pt-4 pl-5">
        <img src="logo.png" class="logo" />
      </div>
      <div class="col-sm-5"></div>
      <div class="col-sm-4">
        <a class="btn btn-primary" href="#" role="button">choice 1</a>
        <a class="btn btn-primary" href="#" role="button">choice 2</a>
      </div>
    </div>
  </div>
</div>

And here is the corresponding CSS code:

.line {
  position: relative;
}

.line::after {
  content: "";
  background-color: #ed1e79;
  position: absolute;
  width: 100%;
  height: 20px;
  top: 90px;
  left: 0px;
  z-index: -1;
}

.btn {
  border-radius: 0 !important;
}

Answer №1

It is recommended that the line is not included as an element in your markup. Instead, consider using it as a background image or a pseudo-element on an existing container element. By doing this, you can take advantage of Bootstrap's flex structure to align the two buttons vertically at the end of the column.

.bg-line {
    background-image: linear-gradient(180deg,
            transparent calc(50% - 6px),
            #ff0000 calc(50% - 6px),
            #ff0000 calc(50% + 6px),
            #ffffff calc(50% + 6px));
}
<link rel="stylesheet" 
  href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css"/>

<div class="bg-line d-flex justify-content-between align-items-end">
    <div class="col"><!-- flexes to fill space -->
        <img src="https://via.placeholder.com/90" class="logo" />
    </div>

    <div class="col-auto btn-group"><!-- shrinks to fit content -->
        <a class="btn btn-primary btn-sm" href="#" role="button">choice 1</a>
        <a class="btn btn-secondary btn-sm" href="#" role="button">choice 2</a>
    </div>
</div>

Check out the Fiddle demo here

Answer №2

To achieve the desired layout, you can use flexbox properties such as d-flex, align-items-end, and justify-content-between.

Here's an example in CSS:

header {
  margin: 10px;
  display: flex;
  justify-content: space-between;
  border: solid 2px black;
  padding: 10px;
  align-items: flex-end;
}

.img {
  height: 100px;
  width: 100px;
  border: solid 2px black;
  border-radius: 50%;
}

.btns {
  height: 20px;
  width: 150px;
  border: solid 2px black;
}
<header>
  <div class="img"></div>
  <div class="btns"></div>
</header>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Click-triggered AJAX request encounters failure

I am encountering a strange issue where an ajax call within an on('click') listener triggered by an external click event will fail, but works fine when the listener is activated through a standard user mouse-click. Below is the HTML code snippet ...

`Set the body height to equal that of the entire document`

Currently facing an issue on the test page when scrolling down: The body element is set to have a height of 100%, but it only takes up the viewport's height, not the entire document height. The goal is for the page to always display at 100% of the d ...

The linear gradient shifts when the screen size is modified

My background features a linear gradient: The issue arises when the screen size changes, as the gradient does not start at Point 0: How can I ensure that the gradient always starts at point 0 regardless of the screen size? (Excluding mobile screens) body ...

Automatically numbering table columns with custom language localization in JavaScript using Jquery

Is there a method to automatically number table data in a local or custom language? As a Bengali individual, I have figured out how to automatically number the first data of each row using css and js. However, I am uncertain about how to implement custom n ...

In what ways can a distant ancestor influence its subsequent generations down the line?

As a beginner utilizing Bootstrap v5, I am in the process of creating a navbar using the following HTML code. Within this code, the parent element (ul) of my link items contains a class called "navbar-nav" which results in my link items being styled to s ...

Remove the "Show Quoted Text" feature from your Gmail experience

How can I code HTML emails to avoid displaying "show quoted text" and preventing text from turning purple? The system I am developing sends a notification to users when they receive a reply, but after two or more replies from the same person, everything ex ...

Utilizing effective CSS media queries within an Angular application

According to what I've read, it is not recommended in Angular to use the CSS hidden element to hide an element like this: .container{ background-color : powderblue; height : 50px; width : 100% } @media (max-width: 400px){ .container{ ...

Arranging text within a td cell

This is what I currently have: <tr> <td colspan="4" style="font-size:7pt; font-color:red; font-weight: bold;"> PLEASE NOTE: SPECIFY THE ARTICLE IN AS MUCH DETAIL AS POSSIBLE </td> </tr> However, the text does not a ...

Shadows appear distorted in Internet Explorer 9

After searching online for how to add shadows to my containers, I came across this code that I applied to my divs: .boxShadow { -webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); -moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); -ms-filter: " ...

An AngularJS-powered dynamic navbar

Apologies if my explanation is unclear, but I am struggling to find a simple way to convey the following information. I have set up a navigation bar that displays different categories of articles. These navigation items are pulled from a database and can ...

An example of a functional AngularJS menu with accordion-style dropdowns, dynamic data, and submenus created using list items (li) - see

My goal is to create a versatile accordion-style navigation menu with submenus in AngularJS. This menu should be able to dynamically load menu data, determine which items have submenus, and more. I have experimented with angular-ui/bootstrap accordion elem ...

"Create a sleek slider with a modern Apple store aesthetic using Javascript

While I am willing to put in some effort, I am a bit lost at the moment. I am attempting to create a slider similar to the one featured on the home section of the Apple website. How can I enable a click on an image to navigate through slides? Alternatively ...

Firebase hosting adjusts the transparency of an element to 1% whenever it detects the presence of CSS opacity

I'm currently working on a website using Vue.js and Firebase. Everything runs smoothly locally, including a button with a desired low opacity. However, when I deploy the site to Firebase Hosting, the button's opacity inexplicably changes to 1% an ...

Utilizing Consistent Styles Across Multiple Components within an Angular 2 Application

In my Angular 2 app, I have some CSS rules that are shared among multiple components. I don't want to duplicate these rules in each component's styles. Currently, I am considering two approaches: Storing common CSS rules in a static CSS file an ...

Achieving a compressed display of an HTML table

My boss recently asked me to enhance the responsiveness of a table on our website. I initially followed the solution discussed in my previous query about making tables responsive (Responsive Table Display) However, after completing that implementation, I ...

Experiencing challenges during the creation of a NUXT build

Trying to build a Nuxt SSR app, but encountering an error related to the css-loader during the build command execution. The issue seems to be with Invalid options object. ERROR in ./node_modules/vue2-google-maps/dist/components/streetViewPanorama.vue (./no ...

What is the best way to position an image beside a jquery dialog box?

Apologies for not finding a suitable topic to discuss. Is it possible to place an image next to a jQuery dialog, similar to the following example? If so, how can this be achieved? ...

Strange occurrences with HTML image tags

I am facing an issue with my React project where I am using icons inside img tags. The icons appear too big, so I tried adjusting their width, but this is affecting the width of other elements as well. Here are some screenshots to illustrate: The icon wit ...

Adjust the size of bootstrap card titles to match up with the image on the page

I am facing an issue where the title of the second card is pushing the image down. Is there a way to dynamically resize the card title to align all the images properly? Any help would be appreciated. https://i.sstatic.net/PRRHl.png Bootstrap Card ...

Having trouble with jQuery's scrollLeft function on elements that are not currently visible

Within a large container DIV that contains numerous other elements and has a scroll bar, an issue arises when determining the value of scrollLeft. When the DIV is visible, the scrollLeft() function returns the correct value, but when the element is hidden, ...