Is it possible to create a similar design that is also responsive?

I've been struggling to create a header for a website project I'm working on. My goal is to design something like the image below:

https://i.sstatic.net/szQGf.jpg

The biggest challenge I'm facing is making this design responsive. The pointed part of the blue section needs to remain unchanged, while the rest of the header should stretch to the right side. My CSS knowledge is limited, and despite my efforts, I haven't found a solution that fits my requirements.

***EDIT: One crucial aspect is that the white space between the logo div and menu bar must be transparent. It would have been simple if it were just a solid color, but it needs to show the background image behind the header :/

Answer №1

To create a responsive website layout, I would start by designing a header with a link for the logo, followed by a navigation bar containing all the necessary links. Using media queries, I would set a minimum width to ensure that all the links fit within the navigation bar, and collapse them at a specific breakpoint:

body {
  width:100%;
  margin: 0;
  padding: 0;
}
header {
  position: relative;
  padding-right: 15px;
}
a.logo {
  position:absolute;
  z-index:1;
  border: 5px solid white;
  border-radius: 50%;
  width: 75px;
  height: 24px;
  top:0;
  left:0;
  background: black;
}
nav {
  position:relative;
  margin: 5px 0;
  height:24px;
  width:100%;
  background: black;
  text-align: left
}
@media (min-width: 767px) {
  nav a {
    display: none;
  }
}
<header>
  <a class="logo">#</a>
  <nav>
    <a>#</a>
  </nav>
</header>

The key components to making this design responsive include:

Answer №2


To achieve the desired layout, you can utilize media queries and Bootstrap 4.0 classes that are specifically designed to help with alignment. For instance, the "ml-auto" class will align your element all the way to the right by setting its margin-left property to auto. There are many other classes available in Bootstrap that you can experiment with to customize your design further. I have crafted a solution using Bootstrap 4 that is fully responsive on various devices including mobile, tablet, and desktop screens. Feel free to add your own classes as needed! Give the code below a try to see how it works:

#nav-header {
            position: relative;
        }

        #nav-header:before {
            content:"";
            width: 80px;
            height: 100%;
            position: absolute;
            top:0;
            left:0;
            background:#fff;
            z-index: 1;
        }
        
        #nav-header .navbar-brand {
            background:#fe0000;
            text-transform: uppercase;
            font-weight: 600;
            color:#fff;
            text-align:center;
            border-radius: 100px;
            border: 10px solid #fff;
            z-index: 4;
        }

        @media (min-width: 320px) {
            #nav-header .navbar-brand {
                padding: 2% 10%;                
            }
        }

        @media (min-width: 768px) {

            #nav-header {
                margin: 25px 0 25px 25px;
            }

            #nav-header .navbar-brand {
                padding: 1.5% 8%;
            }

        }

        @media (min-width: 992px) {
            #nav-header .navbar-brand {
                padding: 1.4% 6%;                
            }
        }



         #nav-header, #navbarSupportedContent {
            background: #003cff;
            padding:0;
         }

         #navbarSupportedContent {
            z-index: 9;
         }

         #nav-header .navbar-nav {
            list-style: initial;
            color: #fff;
         }

         #nav-header .navbar-nav li {
            margin-right: 2em;
            margin-left: 2em;
         }

         #nav-header .navbar-nav > li > a {
            color:#fff; 
            text-transform: uppercase;
            font-weight: 600;           
         }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<nav id="nav-header" class="navbar navbar-expand-lg navbar-light">
      <a class="navbar-brand" href="#">Logo</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item active">
            <a class="nav-link" href="#">Option 1 <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Option 2</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Option 3</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Option 4</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Option 5</a>
          </li>
        </ul>
      </div>
    </nav>

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

Tips on how to remove the first column from a jQuery hover effect

Currently, I have a function that enables hover events on a table. Right now, it excludes the header row but I also need it to exclude the first column. Any suggestions on how to do this? $(".GridViewStyle > tbody > tr:not(:has(table, th))") ...

Which option is more effective: using an id or using !important?

While some say to avoid using the !important rule and others argue that since ids are unique, there is no need to target like #main > #child and you can simply use #child. In my particular case: #main > div{ color: red; } #child{ color: blue;/ ...

What is the best way to incorporate a sliding effect into my cookie form?

I created a cookie consent form for my website and I'm looking to include a sliding effect when it first appears and when it disappears after the button is clicked. How can I implement this sliding effect into the form? Here's the HTML, CSS, and ...

"Utilizing Flask to efficiently manage a multitude of buttons and seamlessly update a

I am working on a web application similar to mini-tweets. The content for the posts is retrieved from a database and I want to include an 'up vote' button for each post, similar to the image shown below. https://i.sstatic.net/kJySO.png Each pos ...

"Utilizing Primeng's P-Table Component for Enhanced Interactivity

https://i.sstatic.net/UQZYV.png Greetings to all! I am currently working with p-table, p-headercheckbox, and p-tableCheckbox along with additional filters for each column. However, I am encountering an issue where the filters are not aligning properly wit ...

Is Bootstrap revolutionizing the world of flex-box layouts?

I'm currently in the process of creating a Simon game, and everything is going smoothly until I introduce Bootstrap into the mix. Suddenly, my "Simon board" starts acting strangely. Here's the troublesome code: HTML: <div class="simon"> ...

Are you struggling with the issue of Function components not being able to be given refs? When you try to access the ref, it just fails. Perhaps you should consider using React.forwardRef

I have implemented the "styled" feature from Material UI to add styles to my components. Right now, I am in the process of cleaning up code to remove console errors. Initially, I encountered this warning message: "Warning: React does not recognize the con ...

Adding complex JSON format to an HTML table involves formatting the data correctly and then using

Utilizing AJAX, I fetched a JSON response and am now looking to map the JSON data into an HTML table structured like this: { "records": [{ "type_id": 000001, "type_desc": "AAAAAA", "type_createby": "Adam" }, { "type ...

How can I extract the text within a Span tag using Selenium WebDriver?

Is there a way to retrieve the text from a span tag and print it using Selenium Webdriver? I am looking to extract the text UPS Overnight - Free The HTML code is as follows: div id="customSelect_3" class="select_wrapper">> <div class="select ...

anchor to # inquiry

I'm curious about the href link and its usage, I tried looking it up online but didn't find much information. Here is an example of a href link I have: <a href='#' onclick='openSerialWindow();return false;'><h:output ...

Is it possible to stack one Canvas on top of another?

Right now, I am engaged in a process that involves: creating a canvas and attaching it to a division applying a background image through CSS to that canvas. drawing a hex grid on the canvas placing PNGs on the canvas. animating those PNGs to show "movem ...

How can you position an element at the bottom of a div using CSS?

Could you please assist me in aligning an element to the bottom of a div using CSS? Below is a screenshot of my webpage for reference: http://prntscr.com/5ivlm8 (I have indicated with an arrow where I want the element to be) Here is the code snippet of m ...

What are some ways to change the appearance of a component using its parent?

In order to make changes to the CSS properties of a Vue component from its parent, effectively overriding any existing styles within the component, I am seeking a solution. Initially, I assumed that styling a component like <my-component> directly f ...

How to display an unordered list horizontally in HTML

I'm working on a screen that has filters displayed vertically, but I want to align them horizontally and have the filter options arranged in two columns. I've tried using CSS properties like spacing, clear, and display block, but the checkboxes/l ...

Can you employ a right-side offset in Bootstrap 4?

Is it possible to align a button with a textbox using the Bootstrap 4 layout system? https://i.sstatic.net/tN9II.png <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/> <div ...

Tips for updating the content of a div with the click of another div

Is there a way to dynamically change the content of a div upon clicking on a menu item? Here is the current layout for reference: https://i.stack.imgur.com/nOnlQ.png Below is the CSS and HTML code snippet: body { background-color: #555657; ...

Adjust the placement of the navigation to the middle of the

Currently working on a webpage using html/css, I came across a stylish navigation bar which I decided to customize. However, I'm facing difficulty in aligning the navigation bar at the center of the header. Here is a snapshot of the current layout: h ...

When attempting to input a value in the middle of the line, the cursor unexpectedly leaps to the end

I have successfully created a code that prevents spaces at the beginning and special characters in an input field. The code is working perfectly, but there is an issue with the cursor moving to the end when trying to type at the beginning or middle of the ...

Concealing HTML pages in Node.js: A step-by-step guide

I have a specific requirement where my website's html pages should only be accessible to users who are logged in. However, when I used the command below, my html pages became public: app.use(express.static('public')); For instance, I do no ...

Text fades into view from the bottom after a line break using CSS and JavaScript

I'm looking to create a unique fade reveal text effect for a multi-line H1. The goal is for each line of the text to fade up from its own row, rather than simply revealing from the bottom. Here's an example I've already developed, but it cu ...