user2479982
user2479982

Reputation: 21

How do I use css to set width to the end of the screen?

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

Upvotes: 2

Views: 3787

Answers (2)

Roberto Ribeiro
Roberto Ribeiro

Reputation: 123

This is an old question, but try:

.class {
    max-width: 100%;
}

Upvotes: 2

Musebo
Musebo

Reputation: 1

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.

Upvotes: 0

Related Questions