The header logo will have an absolute position to overlay the navigation menu when the screen is resized

I am currently working on a website layout that involves using position: absolute for the logo to overlay another div below it, purely for stylistic reasons. While I have achieved this effect, it doesn't translate well into responsive web design. When resizing the browser window, the logo and navigation collide.

Is there a way to reposition the logo above the navigation during resizing while maintaining its correct placement on desktop view?

Please see a snippet of my code below along with a link to the jsfiddle:

https://jsfiddle.net/d9e4gtoj/

.col-12 {
  width: 100%;
}

[class*="col-"] {
    padding: 15px;
    border: 2px solid red;
    display: inline-block;
    vertical-align: top;
    margin-right: -4px;
  }

.container {
    max-width: 99%;
    margin: 22px;
    margin: 0 auto;
    text-align: center;
}

.nav {
    margin-right: -4px;
    font-family: "Lato";
}

.top-nav {
    text-align: right;
    margin-right: 5px;
    padding-top: 52px;
}

.top-nav li {
    display: inline-block;
    vertical-align: top;
    margin: 0 10px;

}

.top-nav {
    text-align: right;
    margin-right: 5px;
    padding-top: 52px;
}
.logo {
    font-size: 82px;
    font-family: 'Suez One', serif;
    color: #3F3A46;
    position: absolute;
    padding-left: 100px;
    margin-top: 40px;
}

ul {
  list-style: none;
}
  <header class="container">
          <h1 class="logo"><a href="index.html">Logo</a></h1>
      <nav class="nav top-nav">
        <ul>
          <li><a href="menu.html">Menu1</a></li>
          <li><a href="menu.html">Menu2</a></li>
          <li><a href="menu.html">Menu3</a></li>
          <li><a href="menu.html">Menu4</a></li>
        </ul>
      </nav>
    </header>
      <section class="container">
        <div class="col-12 banner">
        <h2>Tagline text. Tagline text.<br> Tagline text. Tagline text.</h2>
        </div>
      </section>

Answer №1

After implementing the following CSS code snippet, my issue was successfully resolved:

@media (max-width: 800px) {

  .logo,
  .top-nav {
    margin: 0;
    padding: 0;
  }
  .logo {
    position: relative;
  }

  .top-nav {
    text-align: center;

    }

}

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

The color of the link remains blue when using Firefox

Check out my website at kenastonchiropractic.com When viewing the site in Chrome, the "Home" link remains the same color as the other links and they all turn white when hovered over. However, in Firefox, the "Home" link stays blue even after being clicked ...

Modify the label contents to reflect the selected file, rather than using the default text

Currently, I am working on customizing my file upload input to enhance its appearance. Everything is going smoothly so far, but I am facing difficulty in finding a suitable jQuery script that can meet my specific requirements. My objective is to have the ...

Position the <a> to the right side of the div

Is there a way to right-align the <a> element, which contains a Button with the text Push Me, within the <div> (<Paper>)? https://codesandbox.io/s/eager-noyce-j356qe This scenario is found in the demo.tsx file. Keep in mind that using ...

Input automatically establishes default values

Something strange is happening with my HTML form. When I view it on a browser, default values are appearing in the text and password inputs that I did not set. The text input shows "creator" and the password input shows "*****". This only occurs when I set ...

Learn the process of automatically copying SMS message codes to input fields in Angular17

After receiving the first answer, I made some changes to the code. However, when testing it with Angular, I encountered several errors. How can I resolve these issues? TS: async otpRequest() { if ('OTPCredential' in window) { const ab ...

What is the proper syntax for creating a layout with DIV and CSS?

Is there a way to create a master page for asp.net that includes 3 sections using div elements? I want to split the window into a left pane for tree view navigation, a top banner type div, and a main content window under it where child pages will be loaded ...

Images positioned next to each other appear distorted when adjusting for different screen sizes

I have been struggling with this issue for quite some time and I just can't seem to get it right. My goal is to display two images side by side with a gap between them. The problem arises when the browser is resized, as the gap disappears and the im ...

Modify the button's border color upon click action

I am looking to implement a feature where the border of a button changes when clicked once and reverts back when clicked again. This should apply individually to each of the 16 buttons with the same class. Additionally, I want to enable the ability to clic ...

How can I incorporate a .shtml file into a .php webpage?

Is there a way to include a .shtml file within a .php page? I know it can be done, as I have successfully achieved this in the past (although I cannot remember the exact code). Can someone please assist me with this? ...

arranging elements within a container

<td id="name_3869-0_0" style="position: relative; " colspan="4"> <div style="float:left;width:100%"> <img src="/img/1.gif" align="middle" style="margin-right: 10px;" class="company_symbol" border="0"> <strong style= ...

Inject CSS values dynamically

I am currently working on dynamically setting the color of a div. To provide some context, let's examine the following: <!doctype html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <div clas ...

From Button to Picture Button

Having an issue with my dropdown menu. After selecting a location, clicking on the "go" button should direct me to another page. Here is the HTML code for the button: <input type="button" name="button" class="gobutton" onclick="openDir(this.form);"> ...

Problems with navigation alignment in Flask website due to HTML, CSS, and

Here's a snapshot of my current website design: website I'm attempting to place the Login & Sign up buttons in line with the rest of the navigation bar. I've tried various methods without success so far. My attempts include adjusting text a ...

Managing state changes with a slider in ReactJS

I am currently working with the Foundation slider found at this link: click for doc. To access the slider's current value, they recommend using a hidden input like this: <div class="slider" data-slider data-initial-start="50" data-end="200"> & ...

Integrating external JavaScript widgets into the web application in real-time

I am currently engaged in a React js project that involves the dynamic addition of third party scripts (widgets) to the web app. These widgets encompass various third party platforms such as Twitter, Instagram, Youplay, Youtube, and more. The existing co ...

``Why Ionic 3 Popover Sizes Should Adapt to Different Screen

Currently in my Ionic 3 project, I am utilizing a popover with a set height using the following code snippet: editOpty(rw){ let popover = this.editOptyPopup.create(EditOptyPopoverComponent, rw, { cssClass: 'edit-opty-popover'}); popover ...

Unable to fetch the webpage element object

While attempting to extract data from the historical table on investing.com, I encountered an issue where I couldn't retrieve the column item and an error occurred. Traceback (most recent call last): File "<ipython-input-119-ba739f477693>", ...

js TouchEvent: When performing a pinch gesture with two fingers and lifting one of them up, how can you determine which finger was lifted?

I am currently working on a challenging touching gesture and have encountered the following issue: let cachedStartTouches: TouchList; let cachedMoveTouches: TouchList; function onStart(ev: TouchEvent) { // length equals 2 when two fingers pinch start ...

Tips for creating a captivating full-screen parallax section on your website

Is there a way to make the first section of a parallax site full screen? I've been scouring the internet for a solution to this problem, but I'm not having any luck. Almost every parallax site I come across has their first section full screen, a ...

What steps can be taken to resolve the error message "AttributeError: 'WebElement' object does not have the attribute 'find_element_class_name'?"

try: main = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "main")) ) articles = main.find_elements_by_tag_name("article") for article in articles: header = article.find_element_c ...