The presence of white space at the top of the page is distracting from the overall

Struggling to eliminate the small white space at the top and right side of my design, as well as aligning links in the center when the browser is resized to under 1000px. Links are centered above 1000px.

https://i.sstatic.net/9Nfhp.png

Check out the Fiddle here

* {
            box-sizing: border-box;
        }
        
        @media screen and (max-width:1000px) {
          .navbar {
            display: block;
          }
          .navbar a {
            float: none;
            width: 40%;
          }
        }
        
        .buttonsTop {
          text-align: center;
          outline-color: blue;
          outline-width: 1px;
          outline-style: inset;
        }
        
        .navbar {
          display: inline-block;
          text-align: center;
          padding-left: 5px;
          margin: 5px;
          font-size: 35px;
          font-family: Arial, Helvetica, sans-serif;
        }
        
        .navbar a {
          float: left;
          display: block;
          color: black;
          text-align: center;
          padding: 12px;
          text-decoration: none;
          -moz-transition: all 1s;
          -webkit-transition: all 1s;
          -o-transition: all 1s;
          -ms-transition: all 1s;
          outline-color: red;
          outline-width: 1px;
          outline-style: inset;
        }
        
        .navbar a:hover {
          color: red;
          -moz-transition: all .5s;
          -webkit-transition: all .5s;
          -o-transition: all .5s;
          -ms-transition: all .5s;
          transform: scale(1.3);
          -moz-transform: scale(1.3);
          -webkit-transform: scale(1.3);
          -o-transform: scale(1.3);
          -ms-transform: scale(1.3);
        }
<div class="topImage">
          <div class="buttonsTop">
            <div class="navbar"><a href="#">Home</a></div>
            <div class="navbar"><a href="#aboutmeSection">About Me</a></div>
            <div class="navbar"><a href="#">Portfolio</a></div>
            <div class="navbar"><a href="#">Contact</a></div>
          </div>
        </div>

Answer №1

Some updates have been made to the code. Feel free to take advantage of a reset CSS or create one yourself to clear the user-agent styles.

.buttonsTop{
  text-align: center;
  outline-color:blue;
  outline-width:1px;
    outline-style:inset;
}
.navbar{
    display:inline-block;
    text-align: center;  
    padding-left: 5px;
    margin: 5px;
    font-size: 35px;
    font-family: Arial, Helvetica, sans-serif;  
}
.navbar a{
 float: left;
 display: block;
 color: black;
 text-align: center;
 padding: 12px;
 text-decoration: none;   
 -moz-transition: all 1s;
 -webkit-transition: all 1s;
 -o-transition: all 1s;
 -ms-transition: all 1s; 
outline-color:red;
outline-width:1px;
outline-style:inset;    
}
.navbar a:hover {
 color:  red;
 -moz-transition: all .5s;
 -webkit-transition: all .5s;
 -o-transition: all .5s;
 -ms-transition: all .5s;
     
 transform : scale(1.3);
 -moz-transform : scale(1.3);
 -webkit-transform : scale(1.3);
 -o-transform : scale(1.3);
 -ms-transform : scale(1.3);
}
<head>
<style>
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
@media screen and (max-width:1000px){
     .buttonsTop {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
     .navbar{       
        display:block;
        width: 40%;
     }  
    .navbar a{
        float: none;       
    }
     
}
</style>
<title> MySite </title>
</head>
<body>
<div class= "topImage">
<div class="buttonsTop">
 <div class= "navbar"><a href="#">Home</a></div>
 <div class= "navbar"><a href="#aboutmeSection">About Me</a></div>
 <div class= "navbar"><a href="#">Portfolio</a></div>
 <div class= "navbar"><a href="#">Contact</a></div>
   </div>
 
</div>
</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

What methods can I use to locate and delete body selectors within CSS styling?

Currently, I am in the process of enhancing my PHP skills by identifying and removing body selectors within style tags. The objective is to eliminate any occurrences of body selectors that could potentially alter the body section of my HTML, especially pro ...

Resolving CSS Objects

If two CSS classes share the same derived class, how does CSS determine the correct class to apply? Consider the following example: .ClassA.Left {} .ClassB.Left {} .Left {} Given that the class 'Left' can be assigned to multiple elements, how ...

The functionality of Access-Control-Allow-Origin is not effective in Chrome, yet it operates successfully in Firefox

I'm facing an issue with my code in the HTML file. I have a second file that I want to load content from, and both files are located in the same directory <div id="mainMenu"></div> <script> $(function() { $('#mainMe ...

Continuously duplicating DOM elements while appending

I am currently working on populating the DOM with an array of character images using jquery. jquery for (var i = 0; i < character.length; i ++) { let combatantChoice = $('<div>'); combatantChoice.addClass('col-md-3 ...

Is there a way to automatically wrap every `ul` element in a `div` using JQuery?

Is there a way to automatically wrap all ul elements in div using JQuery? <div id="my_uls"> <ul> <li>Item one</li> <li>Item two <ul> <li>Item one of two</li> </ul> &l ...

The fullCalendar plugin fails to display properly when placed within a tab created using Bootstrap

My current challenge involves integrating fullCalendar into a Bootstrap tab. It works perfectly when placed in the active tab (usually the first tab), however, when I move it to another tab that is not active, the calendar renders incorrectly upon page loa ...

Dealing with text overflow within a column and ensuring that the text always expands horizontally to align with the column width

I have implemented a file input feature that displays the selected file's name in a column. However, when the file name is too long, it expands vertically which causes readability issues. There is an option to force the text to expand horizontally, b ...

Jquery Slidedown causing adjacent div to shift downward

Currently, I am attempting to position a div absolutely using CSS. I have two divs on which I am implementing jQuery slide down and slide up functionalities. The issue I am facing is that when one div slides down, the other div is also affected by the same ...

How do I customize the default styling of a single slider in react-slick?

Looking to enhance the look of slick carousels by customizing prev/next arrows and controlling their position? I'm currently using nextjs13, chakra-ui, react-slick, and vanilla extract. An effective way to customize arrow styles is by passing an arro ...

The behavior of -webkit-border-radius differs from that of -moz-border-radius

My website is displaying differently on Safari compared to Firefox. I want the CSS to make it look consistent across both browsers. I understand that I could use two div boxes - one for the outline and one for the image. However, I prefer how Firefox only ...

What is the method for aligning elements in a single row?

I have integrated bootstrap into my project. The width of the section is set to 350px. Below are the HTML elements I am working with: <form class="form-inline"> <div class="input-group input-group-sm col-xs-5" > <input type="t ...

Differences in divider line width when viewed on Chrome only

While working on a multi-format editable date/time widget, I happened to notice that the divider line in one of the widgets appeared thicker when compared to others (particularly thicker in the one with the red text): https://i.sstatic.net/BVNiT.png Here ...

SVG images are not perfectly aligned with surrounding elements, causing a noticeable discrepancy, which becomes even more pronounced when they are being animated

I've been experimenting with creating animated 3-D bars in a bar graph. To ensure there are no issues with stretching or aspect ratio, I decided to split each bar into three parts: (1) an SVG for the top of the bar, (2) a div with adjustable height fo ...

Hiding a "dl" based on the label content within a "dt" using jQuery

Here is the HTML code I am working with: <dl class="last"> <dt><label class="required">DL TO HIDE</label></dt> <dd class="last"> <div class="input-box"> <select name="options[40]" id ...

Selecting Elements with JQuery

Hey there, I'm a beginner and I'm facing an issue with selecting an element within my navigation list <ul class="subnav"> <li><a href="#">Link 1</a><span class="sub">Description 1</span></li> <li>& ...

Chrome is throwing a syntax error with an unexpected token in jQuery replaceWith

jQuery('div#top').replaceWith('<div id="top"> </div>') When I try to replace the entire content of the top div using jQuery, Chrome gives me an error: "Uncaught SyntaxError: Unexpected token" on the first line. I'm no ...

The datepicker feature has been programmed to only allow past or present dates

I've integrated a date picker on a website like so: <input type="text" id="popupDatepicker" placeholder="Select Date" name="from_date" class="input" size="50" /> Here's the script being used: $(function() { $('#popupDatepicker&apos ...

Trouble connecting an event to a dynamically added button using jQuery

I am currently working on a project that involves creating a dynamic walk-through wizard for users. The code I have developed adds an overlay to the page and generates a container with next and previous buttons. By utilizing Ajax, I populate the container ...

My code is designed to operate exclusively on the initial element containing an ID

Check out this screenshot to see what I'm aiming for. I discovered a solution online that might help me achieve my goal. To test the solution, I set up a simple HTML structure like this: <div id="block"> <img id="img& ...

Place the div at the center within the header

I'm struggling to center the logo in my media query for screens below 479px. Whenever I use margin auto, the image gets pushed to the right by the browser. Here is what I have so far and any assistance would be greatly appreciated. HTML <div clas ...