css overlay right side is cut off

sawa

I am inserting an overlay div with width 100%, but the overlay div is not rendered completely. For some reason, it looks as if it has moved rightward.

Here is fiddle. You can check that the padding on the right side does not show fully.

html

<div class='overlay'>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</div>

css

.overlay {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1000000;
  background-color: rgba(255, 255, 255, 0.85);
  -webkit-transition: opacity .2s linear;
  transition: opacity .2s linear;
  padding: 20px;
}
Incredibly HandSome Samuel

Paddings are not calculated in the width in HTML.

That's why when you set the width to 100% (relative to the window), the padding will go outside the window.

If you wish to fit the size, with the padding, you should not set any width property.

But, in your case, your string is a bunch of "A"s, which will affect the property listed above. In this case, you would need to set the width to 40px shorter than the window width. (Because the padding on the left and right are 20px respectively, 20 + 20 = 40)

document.getElementsByTagName("div")[0].style.width = window.innerWidth - 40 + "px"; 

Apart from that, if you want the "A"s to move to the next line, use this css property:

word-wrap: break-word;

Otherwise, use one of the following two css properties:

overflow: hidden;
white-space: nowrap;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Placing an Element to the right side with CSS

From Dev

Fancybox - Image is overflowing off right side of lightbox

From Dev

bootstrap 3 pull-right button cut off from bottom

From Dev

How to cut off overflow on the left side

From Dev

CSS triangles getting cut off

From Dev

In html /css, is there anyway to have a span "cut off" instead of going on to another line (and visually showing the cut off?)

From Dev

Android Textview cuts off from right side of screen

From Dev

Moving text to right side CSS

From Dev

AutoLayout labels getting cut off on right side of screen

From Dev

IE cuts off right side of text

From Dev

Using CSS to cut off left and right side of an image while scaling a window

From Dev

CSS tooltip getting cut off

From Dev

set UIImageView at the right side off the screen

From Dev

Bulge side of div, cut into side of div effect in CSS

From Dev

CSS Right Side Overflows Left Side

From Dev

CSS - Button with two cut off corners

From Dev

Pure CSS Tooltip: content gets cut off

From Dev

Offscreen toggle menu pushes main content off right side of screen

From Dev

The right side of all the text on my website is getting cut off

From Dev

How to cut off overflow on the left side

From Dev

Right-side of center-positioned div cut off on mobile

From Dev

Text in android layout cut off, how to shift text to the right?

From Dev

set UIImageView at the right side off the screen

From Dev

CSS Right Side Overflows Left Side

From Dev

dropdown button in input-group-btn is cut off on right border

From Dev

How to recover icons off right side of filled Desktop?

From Dev

Centered content when resizing the browser is going off to the right side of the page

From Dev

Android - Video Image is cut from the right side in GLSurfaceView

From Dev

CSS | Dropdown at bottom of page is cut off

Related Related

  1. 1

    Placing an Element to the right side with CSS

  2. 2

    Fancybox - Image is overflowing off right side of lightbox

  3. 3

    bootstrap 3 pull-right button cut off from bottom

  4. 4

    How to cut off overflow on the left side

  5. 5

    CSS triangles getting cut off

  6. 6

    In html /css, is there anyway to have a span "cut off" instead of going on to another line (and visually showing the cut off?)

  7. 7

    Android Textview cuts off from right side of screen

  8. 8

    Moving text to right side CSS

  9. 9

    AutoLayout labels getting cut off on right side of screen

  10. 10

    IE cuts off right side of text

  11. 11

    Using CSS to cut off left and right side of an image while scaling a window

  12. 12

    CSS tooltip getting cut off

  13. 13

    set UIImageView at the right side off the screen

  14. 14

    Bulge side of div, cut into side of div effect in CSS

  15. 15

    CSS Right Side Overflows Left Side

  16. 16

    CSS - Button with two cut off corners

  17. 17

    Pure CSS Tooltip: content gets cut off

  18. 18

    Offscreen toggle menu pushes main content off right side of screen

  19. 19

    The right side of all the text on my website is getting cut off

  20. 20

    How to cut off overflow on the left side

  21. 21

    Right-side of center-positioned div cut off on mobile

  22. 22

    Text in android layout cut off, how to shift text to the right?

  23. 23

    set UIImageView at the right side off the screen

  24. 24

    CSS Right Side Overflows Left Side

  25. 25

    dropdown button in input-group-btn is cut off on right border

  26. 26

    How to recover icons off right side of filled Desktop?

  27. 27

    Centered content when resizing the browser is going off to the right side of the page

  28. 28

    Android - Video Image is cut from the right side in GLSurfaceView

  29. 29

    CSS | Dropdown at bottom of page is cut off

HotTag

Archive