{"id":2883,"date":"2020-06-18T13:19:06","date_gmt":"2020-06-18T12:19:06","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2883"},"modified":"2022-02-17T07:13:48","modified_gmt":"2022-02-17T07:13:48","slug":"multi-single-column-depending-on-screen-size","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/css\/examples\/responsive\/multi-single-column-depending-on-screen-size","title":{"rendered":"Multi \/ single column depending on screen size"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Example with 2 columns of boxes that change to a single column on small screens<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">html<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;div class=\"my_root_container\">\n\n    &lt;a href=\"\/somepage\">\n      &lt;div class=\"my_item_container\">\n        &lt;div>\n          &lt;div class=\"my_item_image\">\n            &lt;img src=\"my_image_default.png\" alt=\"My Image\" >\n          &lt;\/div>\n          &lt;div class=\"my_item_details\">\n            &lt;p class=\"my_item_title\">My Title&lt;\/p>\n          &lt;\/div>\n          &lt;div style=\"clear:both\">&lt;\/div>\n        &lt;\/div>\n      &lt;\/div>\n    &lt;\/a>\n\n\n    &lt;a href=\"\/somepage\">\n      &lt;div class=\"my_item_container\">\n        &lt;div>\n          &lt;div class=\"my_item_image\">\n            &lt;img src=\"my_image_default.png\" alt=\"My Image\" >\n          &lt;\/div>\n          &lt;div class=\"my_item_details\">\n            &lt;p class=\"my_item_title\">My Title&lt;\/p>\n          &lt;\/div>\n          &lt;div style=\"clear:both\">&lt;\/div>\n        &lt;\/div>\n      &lt;\/div>\n    &lt;\/a>\n\n  &lt;\/div><\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">css<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/*---------------------------------------*\/\n\/*---------------------------------------*\/\n\/*----- RESPONSIVE COLUMNS OF BOXES -----*\/\n\/*---------------------------------------*\/\n\/*---------------------------------------*\/\n.my_root_container {\n  clear: both;\n}\n\n.my_item_container {\n  width: 240px;\n  border: 1px solid #CCC;\n  border-radius: 6px;\n  margin-top: 16px;\n  margin-right: auto;\n  margin-left: auto;\n  margin-bottom: 16px;\n  padding-top: 6px;\n  padding-right: 6px;\n  padding-left: 6px;\n  padding-bottom: 6px;\n}\n\n.my_item_image { \n  width: 226px;\n  height: 120px;\n  text-align: center;\n  float: none;\n  margin-left: auto;\n  margin-right: auto;\n}\n\n.my_item_image img {\n  width: 226px;\n  height: 120px;\n  object-fit: contain;\n  margin-top: 0px;\n  margin-right: auto;\n  margin-left: auto;\n  margin-bottom: 0px;\n}\n\n.my_item_details {\n  overflow: hidden;\n  padding: 0px 0px 0px 0px;\n  position: relative;\n  height: 50px;\n}\n\n.my_item_details, .my_item_details a, .my_item_details a:Hover, .my_item_details a:Visited {\n  text-decoration: none;\n}\n\n.my_item_title {\n  font-size: 18px;\n  line-height: 140%;\n  font-weight: bold;\n  color: var(--odac-color-main1);\n  margin: 6px 0px 0px 0px;\n  padding: 0px 0px 6px 0px;\n  text-align: center;\n  width: 100%;\n  \n  position: absolute;\n  top: 50%;\n  transform: translateY(-54%);  \/*For text can need 54%*\/\n}\n\n\/*CHANGE FROM MULTI COLUMN TO SINGLE COLUMN ON SMALL SCREENS *\/\n@media only screen and (max-width: 800px) {\n  \/* When width is less than or equal to 800px *\/\n  .my_root_container {\n    width: 100%;\n  }\n  \n  .my_item_container {\n    float: none;\n  }\n}\n@media only screen and (min-width: 801px) {\n  \/* When width is greater than or equal to 801px *\/\n  .my_root_container {\n    width: 560px;      \/* (2 x odac_post_categories_item_container width) + (4 x odac_post_categories_item_container left right margins) *\/\n    margin-right: auto;\n    margin-left: auto;\n  }\n  \n  .my_item_container {\n    margin-right: 20px;\n    margin-left: 20px;\n    float: left;\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Example with 2 columns of boxes that change to a single column on small screens html css<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[253],"tags":[],"class_list":["post-2883","post","type-post","status-publish","format-standard","hentry","category-responsive"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2883"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2883\/revisions"}],"predecessor-version":[{"id":2887,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2883\/revisions\/2887"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}