Changing Column Width Based on Screen Size using CSS

CSSWeb DevelopmentFront End Technology

To change column width based on screen size, the code is as follows −


 Live Demo

<!DOCTYPE html>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
.sample {
   width: 50%;
   background-color: lightblue;
   height: 200px;
   font-size: 18px;
@media only screen and (max-width: 700px) {
   body {
      margin: 0;
      padding: 0;
   .sample {
      width: 100%;
<h1>Changing column width based on screen size</h1>
<div class="sample">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod, maiores!</div>
<h3>Resize the browser window to 700px and below to see the above div width change to 100%</h3>


The above code will produce the following output −

On resizing the browser window to 700 px −

Published on 12-May-2020 13:13:02