Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I adjust my bootstrap based css code so it is more responsive to the page width?

I created this fiddle as you can see there I have a webpage with two texts, one below another. It works great on wide screens, but when I shrink the webpage - or run the webpage on mobile - it is messed up, like on this screenshot:

enter image description here

I thought about doing it more responsive by adding CSS mobile queries, but then in the code I have:

@media (max-width: 545px) {


.outer{
  width:100%;
  height:330px;
  top:0;
  position:relative;
}

.inner1{
  width:100%;
  height:320px;
  margin-bottom:0px;

}
.inner2{
  width:100%;
  height:330px;
  margin-bottom:0px;

}
}

@media (max-width: 435px) {

.outer{
  width:100%;
  height:380px;
  top:0;
  position:relative;
}

.inner1{
  width:100%;
  height:370px;
  margin-bottom:0px;

}
.inner2{
  width:100%;
  height:380px;
  margin-bottom:0px;

}

}

@media (max-width: 378px) {

 .outer{
  width:100%;
  height:460px;
  top:0;
  position:relative;
}

.inner1{
  width:100%;
  height:450px;
  margin-bottom:0px;

}
.inner2{
  width:100%;
  height:460px;
  margin-bottom:0px;

}

} 

etc., so lot's of values for different screen widths. I suspect there's some other way of doing that, the most responsive way in which I don't need to cover each screen width separately in mobile CSS... Can you give me any hint how could I change my code so it works independently on any device/screen width? Thanks!

like image 586
user3766930 Avatar asked Jul 01 '16 15:07

user3766930


People also ask

Is Bootstrap CSS responsive?

Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.

How does Bootstrap help to implement a responsive design?

Bootstrap is responsive and mobile-friendly from the beginning. Its six-tier grid classes deliver more reasonable control over the layout as well as decide how it will be rendered on various types of devices such as desktops, laptops, tablets, mobile phones, etc.

How do I change the width of a Bootstrap form?

Input Sizing in Formsinput-sm . Set the widths of elements using grid column classes like . col-lg-* and . col-sm-* .


1 Answers

Set minimum width and height for each class so that the page stops adjusting the text with screen resolutions that are too small. Add min-height:123px; and min width:456px; (adjust px as needed) so that they do not overlap on small screens.

Note: This isn't very good for mobile.

like image 56
Adam H Avatar answered Sep 28 '22 19:09

Adam H