What are the best strategies for aligning the content on the front page of my website?

Creative Website Concept Current Progress Snapshot

The initial image showcases the desired appearance for my website. The title is positioned in the center of the header elements and features a sleek black border. Below the header and title, there is an image with a similar black border surrounding it. In the middle section, I envision a search bar also bordered in black. Following that, a section displaying a preview of what the website offers should be visible. However, the second image represents the current state of my progress. I am encountering difficulties, particularly with aligning the title and the header correctly. Any assistance or guidance would be greatly appreciated!

body {
  margin: 0;
  font-family: Cambria;
  height: 757.58px;
  width: 1100px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.header-container {
  display: flex;
  align-items: center;
  background-color: #FFFFFF;
  padding: 20px 0;
  font-size: 28px;
  position: relative;
  top: 5px
}

.header {
  text-align: center;
  position: absolute;
  top: 0px;
}

nav ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
}

nav ul li {
  margin: 0 10px;
  position: relative;
  top: 0px;
}

nav ul li a {
  text-decoration: none;
  color: #91CDB7;
  position: relative;
  top: 0px;
}

.main-content {
  margin: 0 20px;
  text-align: center;
  position: relative;
  top: -10px;
}

.main-content span {
  display: inline-block;
  width: 388px;
  height: 93px;
  border: 2px solid black;
  padding: 10px;
  color: #91CDB7;
  font-size: 58px;
  line-height: 73px;
  position: relative;
  top: 0px;
  left: 100px;
}

.header-container:nth-child(1) {
  justify-content: flex-start;
  position: relative;
  left: 10px;
  top: 10px
  /* Align first header-container to the left */
}

.header-container:nth-child(2) {
  justify-content: flex-end;
  position: relative;
  right: 10px;
  top: 10px;
  /* Align second header-container to the right */
}
<div class="header-container">
  <header>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">Recipes</a></li>
        <li><a href="#">Music</a></li>
      </ul>
    </nav>
  </header>
</div>
<div class="header-container">
  <header>
    <nav>
      <ul>
        <li><a href="#">Contests</a></li>
        <li><a href="#">About me</a></li>
        <li><a href="#">Login</a></li>
      </ul>
    </nav>
  </header>
</div>
<div class="main-content">
  <span>Music Bakery</span>
</div>

The provided code reflects my current progress. Although I had hoped it would address the issues with the title and header layout, it unfortunately falls short.

Answer №1

Your original design has been modified significantly to provide a more user-friendly layout. It is recommended to adjust the fixed heights and widths for better responsiveness with breakpoints in the future. This revised setup reflects the desired overall look you are aiming for.

body {
  margin: 0;
  font-family: Cambria;
  height: 757.58px;
  width: 1200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #FFFFFF;
  padding: 20px 0;
  font-size: 25px;
  position: relative;
  top: 5px
}

.header {
  text-align: center;
  position: absolute;
  top: 0px;
}

nav, nav ul  {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

nav ul li {
  margin: 0 10px;
  position: relative;
  top: 0px;
}

nav ul li a {
  text-decoration: none;
  color: #91CDB7;
  position: relative;
  top: 0px;
}

.main-content-title {
  margin: 0 10px;
  text-align: center;
  position: relative;
  top: -40px;
}

.main-content-title span {
  display: inline-block;
  width: 350px;
  height: 88px;
  border: 2px solid black;
  padding: 10px;
  color: #91CDB7;
  font-size: 58px;
  line-height: 73px;
  position: relative;
}
<body>
  <header>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">Recipes</a></li>
        <li><a href="#">Music</a></li>
      </ul>
    </nav>
    <nav>
      <ul>
        <li><a href="#">Competitions</a></li>
        <li><a href="#">About Us</a></li>
        <li><a href="#">Login</a></li>
      </ul>
    </nav>
  </header>
  <main>
    <div class="main-content-title">
      <span>Melody Makers</span>
    </div>
    <div class="main-content-img">
      <img>
    </div>
  </main>
</body>

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

Utilize a service to automatically update fields based on the user's position

Looking to make updates to certain fields once a geoposition is received for a specific user. Currently, my code looks like this: http://jsfiddle.net/VSph2/10/ Encountering an issue with an "Error: Unknown provider: positionProvider <- position" (onl ...

Is it possible that the font-family attribute is not passed down to the input fields within a

Do the html form input elements like text fields or select boxes automatically inherit the font-family property from the body? For instance: body { font-family: 'Lucida Casual', 'Comic Sans MS'; } The above font will not be applied t ...

How to line up text in HTML so that Unicode characters are aligned to the left and right within

Is there a way to align text on the left and right side of the same line? I experimented with various solutions for non-Unicode text that I found here. However, when it comes to Unicode text, the two parts of the text do not align vertically: https://i.s ...

Steps for Adding an H1 Tag Using GWT

Forgive me for what may be a silly question, but I'm truly struggling to understand how to dynamically add an HTML heading tag to my page using the Google Web Toolkit. My motivation is not related to styling purposes, as any label can be styled. Inst ...

Set the navigation height to fill the entire screen

When the article section expands downwards, the left navigation bar does not extend all the way down. I want the navigation with the background color to expand downwards together with the article text on the right. I attempted to use "height: 100%;" for t ...

Received an unexpected GET request while attempting to modify an HTML attribute

After clicking a button in my HTML file, a function is called from a separate file. Here is the code for that function: function getRandomVideoLink(){ //AJAX request to /random-video console.log("ajax request"); var xhttp = new XMLHttpRequest( ...

tips for scrolling divs horizontally within the main container

I've been attempting to scroll horizontally, but even though the scroll bar is visible, it's not functioning. Here's the code: <!DOCTYPE html> <html> <head> <title>qwe</title> </head> <body> < ...

Angular js is a powerful framework that allows for the seamless transition of views, except for the home

I am currently using the ng-animate module to implement sliding effects for my app views. Each route has its own unique slide animation. Take a look at my simple code below: HTML: <div ng-view ng-animate class="slide"></div> CSS: /*Animatio ...

Is there a method within the blueprintjs tabs component to showcase the tabs at the bottom of the tab panel?

Currently, I am working with Version 4 of Blueprintjs and experimenting with its tabs component. I've been trying to find a way to display the tabs at the bottom of the panel, similar to how they are often seen in spreadsheets. While there is an optio ...

Get rid of just this one specific element using jQuery

I have implemented a feature where tasks are dynamically added to a list when the input is entered and its length is less than or equal to 30 characters, followed by clicking a button. Each task comes with a trash icon for removal, sourced from an externa ...

Integration of JavaScript files in HTML leads to the disappearance of the slider component

After adding two sliders to my web page, I noticed that only one of them is working when I link all the necessary JavaScript files into the HTML page. It seems that the new JavaScript files for the second slider are causing the first slider to not show up ...

issues with the functionality of bootstrap modal

I'm currently working on a project where I need to set up a modal popup using bootstrap. The website I'm working on is organized by departments, so the only part of the code that I have control over is the main body of the site. I have included t ...

The application of knockoutjs bindings is restricted to specific ids and cannot be used on any

In my project, I have multiple views where each one applies bindings to its own tag individually. Here is a snippet of the code: (Please note that some code has been omitted for brevity. For a more complete example, you can view the full fiddle here: http ...

Swipe up to illuminate div when validation fails

My JSP page includes a form with a div that displays error messages when validation fails. The errors are generated server-side, displayed inside the div using struts property tag. However, the issue I'm facing is that the submit button is located fa ...

What is the best method to ensure that my background image is fully visible on a webpage?

I'm attempting to place a background image at the center of my webpage, but unfortunately, the image extends beyond the page boundaries and is only partially visible. Below is my CSS code snippet: body{ background-image: url(../img/music_palace_ ...

Is it possible for a font to exclude the space character?

I'm currently developing a font detection library that must be extremely compact in size, perfect for direct inclusion on every page of a website. I've managed to shrink it down quite a bit already (compressed to 417 bytes). Take a look at it on ...

Tips for addressing the issue of button flickering due to CSS transitions

Is there a solution to prevent flickering without compromising the intended design? The issue arises when hovering over a moving or animated element and accidentally un-hovering because it moves beneath the cursor. <!DOCTYPE html> <html> &l ...

Is there a way to modify the default color when the header is assigned the "sticky" class?

Currently, I am in the process of building my own website and have implemented an exciting hover effect that randomly selects a color from an array and applies it when hovering over certain elements. However, once the cursor moves away, the color reverts b ...

Issue with importing and exporting JavaScript on an HTML file is not functioning as expected

I recently worked on a basic JavaScript project involving export/import and encountered an error when inserting it into the HTML. The error message read: "Uncaught SyntaxError: Cannot use import statement outside a module". I researched this issue on Stack ...

Determining the pageY value of a div element with overflow-y styling

Currently, I have implemented a script that tracks the mouse's position upon hover. My goal is to integrate this script within a div that has overflow-y: scroll The script currently utilizes pageY which identifies the position relative to the windo ...