First of all, let's take a look at the current mobile version of the CompStore theme. Using Chrome DevTools or Responsive Web Designer Tester, select an Apple iPhone 5 (portrait) device to test the site. You will probably be redirected to home page:


In spite of the previous adjustment in the CompStore theme, when a mobile device accesses a theme, CSS rules don't apply some important features, such as colors and the positioning of elements. As a suggestion, let's create a standard declaration of color approach and configure CSS to show only one product when the mobile device accesses the site. How can we implement these new features? Using media queries, of course!
In your favorite code editor, open the compstore.less file available under the app/design/frontend/Packt/compstore/web/css/source directory and use the following CSS 3 code:
@color-compstore: #F6F6F6;
body{
background: @color-compstore;
}
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
body{
background: @color-compstore;
}
.widget .block-promo img{
height: 600px;
}
.products-grid .product-item {
width: 100%;
display: inline-block;
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
body{
background: @color-compstore;
}
.widget .block-promo img{
height: 600px;
}
.products-grid .product-item {
width: 100%;
display: inline-block;
}
}The Magento UI break points predefined variables to identify the scope of media queries, which are as follows:
@screen__xxs: 320 px@screen__xs: 480 px@screen__s: 640 px@screen__m: 768 px@screen__l: 1024 px@screen__xl: 1440 pxSo, in the CSS 3 new proposal, the media queries use the @screen_s variable to define the application of new rules. We will propose via mixin to change the background color, promo image size, and product size inside mobile rules for portrait and landscape purposes.
To apply the changes, follow this recipe:
packt/pub/static/frontend/<Vendor>/<theme>/<locale> directory.var/cache directory.var/view_preprocessed directory.packt/bin directory.php magento setup:static-content:deploy command.write permissions again to the directories.Test the site again to get the new home page, as in the following screenshot:

