2

I'm working on a user style for a website.

There are different divs that are different spaces away from the left border.

I want it so the div ends at the end of the screen.

I thought about something like this

.class {
    width: 100%;
}

However, this doesn't stop at the end of the screen. This continues to go.

How can I make it so it doesn't matter how far away it is from the left side, it always ends at the ending at the right

user2479982
  • 21
  • 1
  • 2
  • 2
    Can you post a complete code example please? – j08691 Jun 12 '13 at 20:51
  • There is no catch-all solution for what you are asking, we need to see your specific code. – dezman Jun 12 '13 at 20:52
  • Sounds like you have margins/borders/paddings you aren't accounting for. – cimmanon Jun 12 '13 at 20:52
  • What do you mean by "This continues to go"? Something that may be useful for you to know is that the width property acts on the width within the context of the parent container element. – OregonTrail Jun 12 '13 at 20:54
  • It shouldn't "continue to go". Can you put the whole **css** here? –  Jun 12 '13 at 21:29
  • Does this answer your question? [How to limit max width and height to screen size in CSS?](https://stackoverflow.com/questions/36253760/how-to-limit-max-width-and-height-to-screen-size-in-css) – Dane411 Dec 06 '21 at 11:07

2 Answers2

2

This is an old question, but try:

.class {
    max-width: 100%;
}
Roberto Ribeiro
  • 123
  • 1
  • 7
0

100% is a dynamic width setting, the div will start on the left and end on the right. It will use the entire width of the page when it has no parent to work with. If the parent is 900 pixels, your .class div will also be 900 pixels.

I am assuming you are using a parent DIV width a static width which is exceeding the borders of the page.

Musebo
  • 1
  • 5