CSS to prevent scrollbars

I am struggling with unwanted horizontal scrolling on my webpage and am looking to create some space above the menus. I have provided a link to a JSFiddle where you can see the layout: http://jsfiddle.net/mount/m5upe9r6/1/

body {
  margin: 0;
  padding: 0;
  width: 100%;
  font: normal 12px/1.5em"Liberation sans", Arial, Helvetica, sans-serif;
}
html {
  padding: 0;
  margin: 0;
}
div {
  width: 100%;
}
.header {
  position: relative;
  width: 100%;
  height: 150px;
  background: #1e5799;
  /* Old browsers */
  background: -moz-linear-gradient(left, #1e5799 0%, #2989d8 40%, #1e5799 100%, #7db9e8 100%);
  /* FF3.6+ */
  background: -webkit-gradient(linear, left top, right top, color-stop(0%, #1e5799), color-stop(40%, #2989d8), color-stop(100%, #1e5799), color-stop(100%, #7db9e8));
  /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(left, #1e5799 0%, #2989d8 40%, #1e5799 100%, #7db9e8 100%);
  /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(left, #1e5799 0%, #2989d8 40%, #1e5799 100%, #7db9e8 100%);
  /* Opera 11.10+ */
  background: -ms-linear-gradient(left, #1e5799 0%, #2989d8 40%, #1e5799 100%, #7db9e8 100%);
  /* IE10+ */
  background: linear-gradient(to right, #1e5799 0%, #2989d8 40%, #1e5799 100%, #7db9e8 100%);
  /* W3C */
  filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1e5799', endColorstr='#7db9e8', GradientType=1);
  /* IE6-9 */
}
.login {
  margin: 0;
  padding: 0px 0px 0 0;
  text-align: right;
  width: 40%;
  position: absolute;
  right: 0;
  bottom: 0;
}
.ribbon {
  background-color: #F70D1A;
  overflow: hidden;
  white-space: nowrap;
  /* top left corner */
  position: absolute;
  left: -625px;
  top: 40px;
  /* 45 deg ccw rotation */
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  transform: rotate(-45deg);
  /* shadow */
  -webkit-box-shadow: 0 0 10px #888;
  -moz-box-shadow: 0 0 10px #888;
  box-shadow: 0 0 10px #888;
}
.ribbon a {
  border: 1px solid #faa;
  color: #fff;
  display: block;
  font: bold 105.25%'Helvetica Neue', Helvetica, Arial, sans-serif;
  margin: 1px 0;
  padding: 10px 50px;
  text-align: center;
  text-decoration: none;
  /* shadow */
  text-shadow: 0 0 5px #444;
}
.logo {
  margin: 0px 0;
  padding: 15px 0px 0px 130px;
  cursor: pointer;
  float: left;
}
.topmenu {
  padding: 25px, 0px, 0px, 0px;
}
.topmenu ul {
  list-style-type: none;
  margin: 0;
  padding: 25px, 0px, 0px, 0px;
  text-align: center;
}
.topmenu ul li {
  display: inline;
}
.topmenu ul li a {
  display: inline;
  margin: 0;
  padding: 22px 16px;
  font-size: 15px;
  line-height: 17px;
  font-weight: bold;
  color: #0000A0;
  text-decoration: none;
  text-align: center;
}
.topmenu ul li.active a,
.topmenu ul li a:hover {
  text-decoration: none;
  color: ;
}
<div class="main">
  <div class="header">
    <div class="ribbon">
      <a href="#">BETA</a>
    </div>
    <!--end of robbon div -->

    <div class="logo" class="unselectable">
      <img src="image/DZB.png" style="width:220px;height:120px" alt="logo">
    </div>
    <!--end of logo div -->

    <div class="login">
      <button name="login" class="add">Login</button>
      <button name="Enquiry" class="upload">Enquiry</button>
    </div>
    <!--end of login div  -->

  </div>
  <!-- end of header div -->
  <div class="topmenu">
    <ul>
      <li><a>Product</a>
      </li>
      <li><a>Contuct us</a>
      </li>
    </ul>
  </div>
  <!--end of Top menu div    -->

  <div class="slide">

  </div>
  <!-- end of slide div -->

</div>
<!-- end of main div  -->

Answer №1

Try setting overflow-y to scroll and overflow-x to hidden.

This solution might help solve the issue.

Answer №2

body {
  margin: 0;
  padding: 0;
  width: 100%;
  font: normal 12px/1.5em"Liberation sans", Arial, Helvetica, sans-serif;
}

This code is effective in preventing scrolling on a webpage, but there may be instances where it causes scrolling issues if there are overflow elements within the body. To avoid this, be sure to include

overflow-x: hidden;

Hopefully, this solution makes sense to you.

Answer №3

The issue lies within your CSS file.

If you adjust the padding for your .logo to: padding: 15px 0px 0px 0px;, it should resolve the problem.

Answer №4

We need to target all the div elements in this scenario. Let's eliminate this particular style div {width: 100%;}

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 for keeping an image stationary when hovering over it

I'm in need of some assistance. Despite my best efforts, I have been unable to achieve the desired outcome. I am looking to create a scenario where an image remains in place even when the mouse hovers over it. Essentially, I want the image to stay vis ...

The jQuery script automatically triggers submission on its own

Does anyone have an idea why the form auto-submits itself? I can't figure out why it's doing that. I'm using query parsley to validate the form in a modal. When a user opens the modal and starts typing in the text area, they must type at l ...

Is it possible to assign cookie values after the html content on a webpage has finished loading?

I've come across information suggesting that cookie values can be set after the HTML content has been sent from a PHP script to the web server. Despite trying to implement this, I seem to be facing difficulties in setting up the cookies as desired. C ...

Ways to customize the appearance of CSS bootstrap 'col' elements?

I'm attempting to customize the styling of bootstrap CSS columns col-xl in order to display 5 or 6 cards/tiles on my webpage instead of just 4 (refer to attached image) without interfering with the other grid layouts. Unfortunately, I am currently str ...

Custom directives are unable to interact with inbuilt directives

var app = angular.module("myDiscuss", []); app.controller("TabController", function() { this.tab = 0; this.subTab = 0; this.like = 0; this.selectLike = function(setTab) { this.like= setTab; }; this.selectTab = function(setTab) { this. ...

Using Bootstrap 4 beta for Form Validation

I'm struggling to grasp the concept of building validation forms. The bootstrap documentation includes a JS code snippet (referred to as starter code) like the one below: <script> // Example starter JavaScript for disabling form submissions if ...

Regular expression used for removing an HTML tag <object> from a string

I'm working with an HTML string that contains some simple text: <div><object height="315" width="560"></object><div><object height="315" width="560"></object></div></div> Is there a way to eliminate an ...

Adjust the text within the paragraph dynamically according to the option chosen in the drop-down menu using

I'm having trouble updating a paragraph in a letter based on the user's selection from a dropdown menu. I can't seem to figure it out. I don't know whether ng-show/hide or ng-options is the best approach for this. I feel completely los ...

Rendering images in Next.js version 10

Just recently, Next.js version 10 was launched featuring the latest Image element, making it a great asset for websites that heavily rely on images! When I receive an HTML response from the server, it looks something like this: HTML = "<div> &l ...

How can I style <p> tags with a specific font in Tailwind Typography?

For instance, suppose I wish to utilize the markdown as shown below: # AAAAAAAAAa BBBBBBB This would then be interpreted in such a way that AAAAAAAAAa is designated as h1, BBBBBBB as <p>, and the entire content enclosed within a prose div utilizing ...

Tips for adjusting animations using @media queries

My animation, , appears correctly on mobile but not desktop. It is too wide on desktop and I have tried adjusting the CSS without success. @media (max-width: 5000px) and (min-width: 768px) {.contact::before.contact::after {content: attr(data-text); posit ...

Is it possible to determine the current scroll position using <a name=#page> in JavaScript?

I am currently in the process of creating a website to showcase a comic, with each page being accessed by scrolling using < a name=#page(number) > in HTML. For example, the button to navigate to the next page would look like this: <a href="#page ...

Alter the class of the div element every three seconds

Greetings, I trust everyone is doing well. I am in need of some assistance from your brilliant minds. I have a circular div along with three CSS classes, and my objective is to switch the div's class and update the label text every 3 seconds. Any insi ...

How do I link data from a boostrap modal in vue.js?

To display a bootstrap modal, we can utilize the data-toggle attribute. For instance: <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#msg">Open Modal</button> I want to show the modal by using a boolean var ...

How can I adjust the brightness, contrast, saturation, and hue in HTML5?

Is there a way to adjust the brightness without turning the image grey? I've been attempting to do so, but only managed to change it to greyscale. My objective is to increase and decrease the brightness of the image. Here is the current code: HTML ...

Stripping away HTML tags from a JSON output

I'm attempting to retrieve a JSON result using jQuery. $.ajax({ type: "GET", url: "http://localhost:8080/App/QueryString.jsp?Query="+query, contentType:"text/html; charset=utf-8", dataType: "json", success: function(json) { if(data!="") ...

Identifying a span element and appending to its classList

I am currently working on code that generates spans, and my objective is to adjust the color of specific spans based on their text content. I have identified a section where I need assistance with the syntax of the code I should input. My aim is to locate ...

Accessing PHP variables within the HTML portion of a PHP document

Setting up my own contact form for the first time using PHP has been a learning experience. While I am able to receive emails from the form, I'm struggling to display the user-inputted information in the email. The HTML <label for="name"> ...

A step-by-step guide to designing a sidebar with navigation menus, including dropdown options for select menu items

Hello, I am looking to design a side navigation bar that includes menus with dropdown options. Can someone provide assistance with this task? The selected menu will determine the content displayed on the main page using angular ng-view. ...

Difficulty in arranging DIVs on a flat surface

As a user running Win XP with Firefox, IE, and Google Chrome browsers, I'm encountering an issue where I can't seem to align two DIVs on the same horizontal plane. My goal is to have the left div occupy 24% of the screen width while the right div ...