A division of text is colliding with a division that holds a list with no particular

Hello everyone, I am new to HTML/CSS and I am facing an issue that I believe can be easily resolved. Currently, my code has four sections, with the last three displaying as expected in a consecutive manner. However, the second section is overlapping on top of the first one. To fix this, I added padding using an ID for the second section, but the padding is applied from the top of the page rather than the section above it. If I remove the padding, "About Me" overlaps with the background of the first section containing links.

#firstlink {
  padding: 15px 50px 0px 0px
}
#linkbar {
      background-color: blue;
      height: 15%;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
}
li {
  font-size: 35px;
  padding: 15px 10px 0px 0px;
  float: right;
  display: inline;
}
#aboutme {
  padding: 75px 0px 0px 0px;
}
<section id="linkbar">
  <ul>
    <li id="firstlink">link1</li>
    <li>link2</li>
    <li>link3</li>
  </ul>
</section>
<section id="aboutme">
  <h1>About Me</h1>
</section>
<section>
  <h1>My Portfolio</h1>
</section>
<section>
  <h1>Contact Me</h1>
</section>

Answer №1

Check out this awesome fiddle, it seems to be exactly what you're looking for - https://jsfiddle.net/swarn_singh/tv25eq3g/

#firstlink {
  padding: 15px 50px 0px 0px
}
#linkbar {
      background-color: blue;
      height: 15%;
      top: 0;
      left: 0;
      width: 100%;
}
li {
  font-size: 35px;
  padding: 15px 10px 0px 0px;
  float: right;
  display: inline;
}
.clear{
  clear: both;
}

Answer №2

#firstlink {
  padding: 15px 50px 0px 0px
}
#linkbar {
      background-color: blue;
      width: 100%;
      height: 15%;
      display: inline-block;
}
ul{
  list-style-type:none;
  padding: 0px;
  margin: 0px;
  float: right;
}
ul li {
  font-size: 35px;
  padding: 15px 10px 0px 0px;
  display: inline-block;
}
#aboutme {
  padding: 75px 0px 0px 0px;
}
<section id="linkbar">
  <ul>
    <li id="firstlink">link1</li>
    <li>link2</li>
    <li>link3</li>
  </ul>
</section>
<section id="aboutme">
  <h1>About Me</h1>
</section>
<section>
  <h1>My Portfolio</h1>
</section>
<section>
  <h1>Contact Me</h1>
</section>

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

choose a selection hopscotch

Is there a way to prevent the input field from jumping out of alignment when an option is selected in these q-select inputs? I want to fix this issue so that the field remains in line with the horizontal alignment. https://codepen.io/kiggs1881/pen/RwENYEX ...

Sorting `divs` based on the number of user clicks in JavaScript: A simple guide

I've implemented a script that tracks the number of clicks on each link and arranges them based on this count... Currently, everything is functioning correctly except when the <a> tags are nested inside a div. In such cases, the script ignores ...

Incorporating a CSS Module into a conditional statement

Consider the following HTML structure <div className={ `${style.cell} ${cell === Player.Black ? "black" : cell === Player.White ? "white" : ""}`} key={colIndex}/> Along with the associated CSS styles .cell { ...

Leverage the greater than operator within an AngularJS controller

This is the data stored in my controller: $scope.data = [{ "F": "1,26,000" }]; $scope.data2 = [{ "F": "26,000" }]; Now I want to implement an if-else condition using this data: if (Number($scope.d ...

Disable the movement and dragging functionality of the scroll feature in Google Maps using React

I have a map.jsx file in my React application that contains the code below: import React from 'react'; import GoogleMapReact from 'google-map-react'; import './map.css'; const Map = ({ location, zoomLevel }) => ( <d ...

Bring to life the div that has been clicked

There are three divs labeled as "left", "active", and "right" in my setup: Whenever the left div is clicked, it animates to become active and the previously active one moves into its place. I want this same functionality to apply to the right div as well. ...

Animating numerous elements simultaneously during Vue component rendering

Take a look at this simple case in the following jsfiddle: https://jsfiddle.net/hsak2rdu/ I attempted to swap and animate two elements, but it didn't work as expected. When you click the toggle button in the playground, the second element quickly mo ...

Having trouble getting the CSS Hover state to function properly?

I am currently working with a code snippet that looks like this: <div style="position: absolute; margin-left: -22px; margin-top: -22px; left: 502px; top: 379px; z-index: 380; display: block;" class="maptimize_marker_0 f st">1<span class="pinlabel ...

Using jQuery and AJAX to dynamically pass a variable into the URL parameter in dynamic HTML pages

By utilizing jQuery, I am dynamically updating the content of a div with a form that consists of two textboxes and a button. Upon clicking this button, ajax is employed to retrieve results from a public webservice based on the data gathered from the textbo ...

Flexbox functionality with a specific focus on Kindle Fire device compatibility

I'm curious about the support for flexbox on Kindle devices and looking for more information on overall support. It seems that some properties like display:flex and flex-wrap:wrap/nowrap are not supported, at least on older Kindle Fire devices (newer ...

Unexpected behavior from Jquery

Users can select options that reveal more choices and text boxes upon clicking. Despite copying and pasting the code for all options, one specific part is not working as expected. The rest of the options function correctly. The code snippet causing issue ...

Homepage featuring a stacked image background similar to Kickstarter

I am trying to replicate the stacked image effect seen on kickstarter.com. However, I am facing an issue where the images do not overflow on the screen as desired. The arrow indicates the area that needs to be filled with the image. Check out the image he ...

Looking for assistance with HTML/CSS code

Adding the code snippet below into my Shopify product-liquid file caused chaos on the page, altering the font and even changing the shape of the add to cart button... The problematic code is shown below: <div id="shopify-section-product-icon-gallery" ...

Dynamic card resizing to fit changes in window size

Hey, I'm currently working on a card layout and have hit a roadblock. I'd like the images to shrink as the window size decreases proportionally. Goal: Images should decrease in size until 600px width while staying centered up to that point. I& ...

The copying of array values is not supported by Chromium

While utilizing Webworker to process an array of pixels from Canvas and then assign it back, I encountered a strange behavior. Firefox works flawlessly in this scenario, however, Chromium seems to insert an empty pixel array into the Canvas. Upon further ...

What is the process for retrieving the API configuration for my admin website to incorporate into the Signin Page?

My admin website has a configuration set up that dynamically updates changes made, including the API. However, I want to avoid hardcoding the base URL for flexibility. How can I achieve this? Please see my admin page with the config settings: https://i.st ...

When you click on the button, the section will not be displayed

I'm facing an issue with my code. I have a set of five buttons and corresponding sections. When a button is clicked, the active and active-btn classes are supposed to be added to that button as well as the corresponding section element with the same i ...

What is the best approach to retain a user's selection for dark mode?

I have created a small website to showcase my work, but I'm struggling to figure out how to make the website remember a user's choice of dark mode. After searching on Stack Overflow, I came across suggestions like using cookies or localStorage. ...

How can I use a CSS file in PHP to conceal the folder structure?

main.css $theme->assign('css_file',SITE_URL.'styles.php?theme='.THEME_ID); $theme->display(TEMPLATES_PATH.'header.tpl'); header.tpl <link rel="stylesheet" href="{$css_file}"> styles.php include TEMPLATES_PATH. ...

Leveraging image values for selecting an image from a collection and showcasing it (Javascript)

I have a collection of images that I want to enlarge upon clicking. Here is what I currently have: <div class="gallery"> <div> <img src="content/imggallery/img1.jpg" class="oldimg" value="0"> </div> ...