prevent scrolling css code example

Example 1: disable scroll css

/* Answer to: "disable scroll css" */

/*
  You must set the height and overflow of the body, to disable
  scrolling.
*/

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden
}

Example 2: javascript disable scrolling on body

document.body.style.overflow = 'hidden';

Example 3: css how to prevent horizontal scrolling

body {
    overflow-x: hidden !important;
}
.container {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

Example 4: css how to prevent horizontal scrolling

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

Example 5: css prevent background scrolling

<body scroll="no" ></body>

or css

background-attachment: fixed;

Tags:

Css Example