Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use 100% div width, if 50% width is too small

Tags:

html

css

How could one go about creating a div, that would have a default size of XX%, however, if the screen gets too small it would switch into 100% size? I have tried using min-width property but the problem with this is that it will not be responsive after the min-width is reached and will overflow if the screen is even smaller.

like image 708
Meowxiik Avatar asked Dec 18 '25 06:12

Meowxiik


1 Answers

You have to use @media queries. So let's say you have a <div> that should take up only 50% of the web page and then you need to show it full width once it enters mobile phone, say 640px width:

div {
  width: 50%;
}

@media screen and (max-width: 640px) {
  div {
    width: 100%;
  }
}
like image 167
Praveen Kumar Purushothaman Avatar answered Dec 19 '25 22:12

Praveen Kumar Purushothaman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!