The media queries are working but the query for ipad get's over ruled with normal media query when resizing browser
Query being used is or over ruled is:
#products-list li:nth-child(3n+1) {
clear: left;
}
Instead of:
#products-list li:nth-child(2n+1) {
clear: left;
}
Normal Query:
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) {
#menu #burger {
display: none;
}
#menu ul {
display: block;
max-width: 850px;
margin: 0 auto;
text-align: center;
}
#menu ul li {
display: inline-block;
text-align: center;
}
#menu ul li:nth-child(8n) {
clear: left;
margin-top: 26px;
}
#menu ul li a {
padding: 8px 16px;
transition: all .5s ease;
}
#menu ul li a:hover {
background: #000;
color: #fff;
}
#menu #lines {
max-width: 300px;
margin: 20px;
padding-top: 35px;
margin: 0 auto;
}
#menu #lines .line {
border-bottom: 1px solid #000;
}
#menu #lines #line-1 {
width: 100%;
margin-bottom: 10px;
}
#menu #lines #line-2 {
width: 66%;
margin-bottom: 10px;
margin: 0 auto;
}
#menu #lines #line-3 {
width: 33%;
margin: 0 auto;
margin-top: 10px;
}
#search-wrapper {
position: relative;
}
#search-box {
margin: 0 35px;
max-width: 250px;
float: right;
}
.nav-section {
margin: 0 35px;
margin-top: 15px;
}
#navbar #nav-left, #navbar #nav-right {
margin: 0;
}
#nav-right {
float: right
}
#products-container {
padding: 35px;
padding-top: 35px;
padding-bottom: 0;
}
#products-list {
margin: -17px;
}
#products-list li {
width: calc(33.33% - 35px);
display: inline-block;
float: left;
margin: 0 17px 0 17px;
}
#products-list li > div {
margin-bottom: 35px;
}
#products-list li:nth-child(3n+1) {
clear: left;
}
}
Below this line of code get's over ruled with the code obuve #products-list li:nth-child(3n+1);
#media only screen
and (min-width: 768px)
and (max-width: 1024px) {
#nav-right {
float: right
}
#products-container {
padding: 35px;
padding-top: 20px;
padding-bottom: 0;
}
#products-list {
margin: -20px;
}
#products-list li {
width: calc(50% - 20px);
display: inline-block;
float: left;
margin: 0 10px 0 10px;
}
#products-list li > div {
margin-bottom: 35px;
}
#products-list li:nth-child(3n+1) {
clear: left;
}
}
Related
For days Ive been trying to correct an error in my CSS for this website. Everything is fine except for the footer area. It looks fine on desktop but as soon as its seen on small screen the footer area doesn't respond, the background colour disappears and and it gets very messy. If someone could help me id greatly appreciate it. Im no expert on CSS and am shooting in the dark.... the site is a test # http://test.apinchofsalt.ie/wp/
All i need is the simplest solution to fix it. thanks very much. Below is the relevant CSS (it includes footer widgets, site footer and media queries)
/* Footer Widgets
---------------------------------------------------------------------------------------------------- */
.footer-widgets {
background-color: #222;
color: #c8c8c8;
clear: both;
font-size: 14px;
font-size: 1.4rem;
}
.footer-widgets .wrap {
overflow: hidden;
padding: 60px 30px 30px;
}
.footer-widgets-1,
.footer-widgets-2,
.footer-widgets-3 {
padding: 0 2.8%;
width: 33.3333333333%;
}
.footer-widgets-1,
.footer-widgets-2 {
float: left;
}
.footer-widgets-3 {
float: right;
}
.footer-widgets .widget {
margin-bottom: 30px;
word-wrap: break-word;
}
.footer-widgets a:focus {
color: currentColor;
}
.footer-widgets li {
background: url(images/icon-li-footer.png) no-repeat 0 7px;
background-size: 8px 8px;
}
.footer-widgets .search-form {
width: 100%;
}
/* Site Footer
---------------------------------------------------------------------------------------------------- */
.site-footer {
color: #222;
font-size: 12px;
font-size: 1.2rem;
padding: 40px 0;
text-align: center;
text-transform: uppercase;
}
.site-footer a {
color: #222;
}
.site-footer p {
margin: 0;
}
/* Media Queries
---------------------------------------------------------------------------------------------------- */
#media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-device-pixel-ratio: 1.5) {
.search-form input[type="search"] {
background-image: url(images/icon-search#2x.png);
}
.sidebar li {
background-image: url(images/icon-li#2x.png);
}
.footer-widgets li {
background-image: url(images/icon-li-footer#2x.png);
}
.content #genesis-responsive-slider .flex-direction-nav li a {
background-image: url(images/icon-direction-nav#2x.png);
}
.content #genesis-responsive-slider .flex-control-nav li a {
background-image: url(images/icon-control-nav#2x.png);
}
.genesis-nav-menu > .rss > a {
background-image: url(images/icon-rss#2x.png);
}
.genesis-nav-menu > .twitter > a {
background-image: url(images/icon-twitter-nav#2x.png);
}
}
#media only screen and (max-width: 1200px) {
.site-container {
max-width: 960px;
}
.site-header .widget-area {
width: 700px;
}
.content {
width: 660px;
}
.sidebar-primary {
width: 300px;
}
.title-area {
width: 260px;
}
.breadcrumb {
margin: -30px -40px 30px;
}
.content {
padding: 30px 40px 10px;
}
.site-header .genesis-nav-menu a {
padding: 38px 14px 40px;
}
.content #genesis-responsive-slider .flex-control-nav,
.content #genesis-responsive-slider .flex-direction-nav li a,
.content #genesis-responsive-slider .flex-direction-nav li a.prev {
display: none;
}
}
#media only screen and (max-width: 1023px) {
.site-container {
max-width: 768px;
}
.content,
.sidebar-primary,
.sidebar-secondary,
.site-header .widget-area,
.title-area,
.wrap {
width: 100%;
}
.header-image .title-area,
.header-image .site-title,
.header-image .site-title a {
background-position: center !important;
float: none;
margin: 0 auto;
}
.genesis-nav-menu li,
.site-header ul.genesis-nav-menu,
.site-header .search-form {
float: none;
}
.genesis-nav-menu,
.site-header .search-form,
.site-header hgroup,
.site-title {
text-align: center;
}
.genesis-nav-menu a,
.genesis-nav-menu > .first > a,
.genesis-nav-menu > .last > a,
.site-header .genesis-nav-menu a {
padding: 16px;
}
.site-header .search-form {
margin: 16px auto ;
}
.genesis-nav-menu li.right {
display: none;
}
.content #genesis-responsive-slider .slide-excerpt {
display: none;
}
.sidebar .widget {
padding: 30px;
}
.comment-list li.depth-1,
.ping-list li.depth-1 {
margin: 30px 0;
}
.footer-widgets .widget-area {
padding: 0;
}
.site-footer p {
padding-left: 30px;
padding-right: 30px;
}
}
#media only screen and (max-width: 800px) {
.site-container {
max-width: 630px;
}
.five-sixths,
.footer-widgets-1,
.footer-widgets-2,
.footer-widgets-3,
.four-sixths,
.home-middle .widget,
.home-top .widget,
.one-fourth,
.one-half,
.one-sixth,
.one-third,
.executive-pro-portfolio .portfolio,
.three-fourths,
.three-sixths,
.two-fourths,
.two-sixths,
.two-thirds {
margin: 0;
width: 100%;
}
.site-title {
margin-bottom: 20px;
}
/* Genesis Responsive Menus */
.js .site-header nav .wrap {
padding: 0;
}
nav.genesis-responsive-menu {
background: #fff;
display: none;
position: relative;
}
.genesis-skip-link .skip-link-hidden {
display: none;
visibility: hidden;
}
.menu-toggle,
.sub-menu-toggle {
border-radius: 0;
border-width: 0;
color: #64c9ea;
display: block;
margin: 0 auto;
overflow: hidden;
text-align: center;
visibility: visible;
}
.menu-toggle:focus,
.menu-toggle:hover,
.sub-menu-toggle:focus,
.sub-menu-toggle:hover {
background-color: #fff;
color: #222;
border-width: 0;
}
.menu-toggle:focus,
.sub-menu-toggle:focus {
outline: 1px solid #ccc;
outline-offset: -1px;
}
.menu-toggle {
background-color: #fff;
line-height: 20px;
margin-bottom: 1px;
position: relative;
z-index: 1000;
width: 100%;
}
.menu-toggle::before {
margin-right: 10px;
text-rendering: auto;
}
.sub-menu-toggle {
background-color: transparent;
float: right;
padding: 14px 10px 13px;
position: absolute;
right: 0;
top: 0;
z-index: 100;
}
.sub-menu .sub-menu-toggle {
padding: 9px 10px;
}
.sub-menu-toggle::before {
display: inline-block;
margin-top: 5px;
text-rendering: auto;
-webkit-transform: rotate( 0 );
-ms-transform: rotate( 0 );
transform: rotate( 0 );
-webkit-transition: transform .25s ease-in-out;
-ms-transition: transform .25s ease-in-out;
transition: transform .25s ease-in-out;
}
.sub-menu-toggle.activated::before {
-webkit-transform: rotate( 180deg );
-ms-transform: rotate( 180deg );
transform: rotate( 180deg );
}
.genesis-responsive-menu ul {
border-bottom: 2px solid #f2f2f2;
}
.genesis-responsive-menu .genesis-nav-menu .menu-item {
display: block;
float: none;
position: relative;
text-align: left;
}
.genesis-responsive-menu .genesis-nav-menu .menu-item:focus,
.genesis-responsive-menu .genesis-nav-menu .menu-item:hover {
background: transparent;
position: relative;
}
.genesis-responsive-menu .genesis-nav-menu a:focus,
.genesis-responsive-menu .genesis-nav-menu a:hover {
color: #64c9ea;
}
.genesis-responsive-menu .genesis-nav-menu .menu-item a {
background: transparent;
border: none;
color: #222;
margin-bottom: 1px;
padding: 15px 20px;
width: 100%;
}
.genesis-responsive-menu .genesis-nav-menu .sub-menu {
border: none;
}
.genesis-responsive-menu .genesis-nav-menu .menu-item > a:focus ul.sub-menu,
.genesis-responsive-menu .genesis-nav-menu .menu-item > a:focus ul.sub-menu .sub-menu {
left: 0;
margin-left: 0;
}
.genesis-responsive-menu .genesis-nav-menu > .menu-item-has-children > a::after {
content: none;
}
.genesis-responsive-menu .genesis-nav-menu .sub-menu {
clear: both;
display: none;
margin: 0;
opacity: 1;
padding-left: 15px;
position: static;
width: 100%;
}
.genesis-responsive-menu .genesis-nav-menu .sub-menu .sub-menu {
margin: 0;
}
.home-middle,
.home-top,
.genesis-pro-portfolio .pro-portfolio.entry .entry-header .entry-title {
text-align: center;
}
.home-cta .button.alignright {
float: none;
margin: 16px 0 0;
}
.footer-widgets-1 {
margin: 0;
}
}
#media only screen and (max-width: 500px) {
.entry-title {
font-size: 24px;
font-size: 2.4rem;
}
.content .entry-header .entry-meta .entry-comments-link {
display: none;
}
}
#media only screen and (max-width: 270px) {
.header-image .site-title a {
background-size: contain !important;
}
.site-title {
font-size: 26px;
font-size: 2.6rem;
}
}
In your media queries pls include the following code. The footer widgets are floated and thus need clearing for the background to wrap around properly.
.footer-widgets .wrap:after {
content: "";
display: table;
clear: both;}
I have tried everything and failed. My current WordPress theme is not so mobile friendly, in fact, even at 768x1024 resolution it goes all crazy. I have only adjusted the content width, and sidebar width.
It is perfect at most of the screens, but if I try to view it on other devices, such as iPad, Kindle, it doesn't look right.
Screenfly iPad view: http://quirktools.com/screenfly/#u=http%3A//tryonlineroulette.com/&w=768&h=1024&a=22
Live website demo: http://tryonlineroulette.com
And here is the code that is responsible for mobile or different resolution view:
/***** Media Queries *****/
#media screen and (max-width: 1024px) {
.mh-container { width: 980px; }
#main-content { width: 630px; }
.main-nav { width: 100%; }
.loop-header, .loop-thumb { width: 100%; float: none; margin-right: 0; }
.loop-thumb, .loop-header .entry-meta { margin-top: 20px; }
.entry-title-wrap, .entry-meta-wrap { float: none; width: 100%; }
.entry-title-wrap { margin-bottom: 20px; margin-bottom: 1.25rem; }
.entry-header .entry-meta { float: left; }
.commentlist ul, .commentlist ol { margin: 0 0 30px 0; margin: 0 0 1.875rem 0; }
.commentlist ul ul, .commentlist ol ol { margin: 0; }
}
#media screen and (max-width: 767px) {
.mh-container { max-width: 440px; width: 90%; }
#main-content, #main-sidebar { float: none; width: 100%; margin-right: 0; }
#main-content { margin-bottom: 30px; margin-bottom: 1.875rem; }
[class*='mh-col-'] { float: none; width: 100%; margin: 0; }
.js .slicknav_menu { display: block; }
.js .main-nav { display: none; }
.header-wrap { padding: 0; }
.logo { padding: 40px 0; padding: 2.5rem 0; }
.latest-news-widget .news-item { margin-bottom: 30px !important; margin-bottom: 1.875rem !important; }
}
Any help will be much appreciated!
Thanks
How can I center align the logo on this header? Also wanted to know how to enable background transparency for header background color and change the value for maximum size for the logo. Here is the CSS entry for the header section.
#header {
display: block;
position: relative;
z-index: 600;
/* Higher than the sidebar widget and widget container, sliders */
margin: 0;
padding: 0;
width: 100%;
background: #2F2E3C; }
#header > .inner {
position: relative; }
#header > .inner > .wrap {
position: relative;
min-height: 76px; }
#media only screen and (max-width: 1024px) {
#header > .inner > .warp {
min-height: 80px; } }
#media only screen and (max-width: 767px) {
#header > .inner {
text-align: center; }
#header > .inner > .wrap {
min-height: 40px; } }
#header.sticky {
position: fixed;
z-index: 999;
width: 100%; }
#media only screen and (max-width: 767px) {
#header.sticky {
position: static !important; } }
#header.sticky .wrap {
min-height: 0; }
.boxed #header.sticky {
max-width: 1180px;
width: 96%; }
.admin-bar #header.sticky {
top: 32px; }
#header.sticky #site-logo {
top: 10px; }
#header.sticky .dropdown-menu-wrap > ul.menu > li > ul.sub-menu {
top: 60px; }
#header.sticky #primary-menu > ul.menu > li > a {
line-height: 60px; }
#header.sticky #top-header-area {
display: none; }
#site-logo {
position: relative;
display: inline-block;
float: left;
left: 0;
top: 30px;
line-height: 0;
margin: 0; }
#site-logo a {
font-size: 28px;
color: #494D4E;
line-height: 36px;
direction: ltr;
display: block;
text-align: left;
/* Do not let logo get bigger than the header */
font-family: "Lato", Arial, Helvetica, Verdana, sans-serif; }
#media only screen and (max-width: 767px) {
#site-logo a {
display: inline-block;
text-align: center; } }
#site-logo a img {
max-height: 100%;
max-width: 100%; }
#media only screen and (max-width: 767px) {
#site-logo {
display: block;
float: none;
position: relative;
margin: 0 auto;
top: 0;
padding: 10px 0; }
#site-logo a img {
max-width: 75%;
margin: 0 auto; } }
#site-description {
margin: 0; }
#container {
background: #f7f7f7;
Edit:
#header {
display: block;
position: relative;
z-index: 600;
/* Higher than the sidebar widget and widget container, sliders */
margin: 0;
padding: 0;
width: 100%;
background: #2F2E3C; }
#header > .inner {
position: relative; }
#header > .inner > .wrap {
position: relative;
min-height: 76px; }
#media only screen and (max-width: 1024px) {
#header > .inner > .warp {
min-height: 80px; } }
#media only screen and (max-width: 767px) {
#header > .inner {
text-align: center; }
#header > .inner > .wrap {
min-height: 40px; } }
#header.sticky {
position: fixed;
z-index: 999;
width: 100%; }
#media only screen and (max-width: 767px) {
#header.sticky {
position: static !important; } }
#header.sticky .wrap {
min-height: 0; }
.boxed #header.sticky {
max-width: 1180px;
width: 96%; }
.admin-bar #header.sticky {
top: 32px; }
#header.sticky #site-logo {
top: 10px; }
#header.sticky .dropdown-menu-wrap > ul.menu > li > ul.sub-menu {
top: 60px; }
#header.sticky #primary-menu > ul.menu > li > a {
line-height: 60px; }
#header.sticky #top-header-area {
display: none; }
#site-logo {
position: relative;
float: left;
left: 0;
top: 30px;
line-height: 0;
margin: 0; }
#site-logo a {
font-size: 28px;
color: #494D4E;
line-height: 36px;
direction: ltr;
display: block;
text-align: left;
/* Do not let logo get bigger than the header */
font-family: "Lato", Arial, Helvetica, Verdana, sans-serif; }
#media only screen and (max-width: 767px) {
#site-logo a {
display: inline-block;
text-align: center; } }
#site-logo a img {
margin:auto;
max-height: 100%;
max-width: 100%; }
#media only screen and (max-width: 767px) {
#site-logo {
display: block;
float: none;
position: relative;
margin: 0 auto;
top: 0;
padding: 10px 0; }
#site-logo a img {
max-width: 75%;
margin: 0 auto; } }
#site-description {
margin: 0; }
#container {
background: #f7f7f7; }
Remove display: inline-block; from #site-logo then add margin:auto; to #site-logo a img.
Edit: I also noticed you have float:center; in #site-logo which is not a valid property, so I would consider removing it as it is redundant.
I am working on a mobile responsive website.
I have the navigation menu with the fixed position.
Right after I close the nav-menus div I have an image that has to be right under it. The thing is that the image goes under the fixed div of the menu.
What is the solution for this?
I want the yellow banner to be fully visible under the nav bar. now it's just under + behind it.
This is an example of what I have :
HTML code:
<!DOCTYPE html>
<html >
<body style="height:100%;">
<div data-role="panel" id="menu" class="" style="padding: 45px 0; margin: 0; " >
<div class="ui-panel-inner">
// the main menu in the background
</div>
</div>
<div id="superDiv" style="background-color: white; -webkit-transition: width 2s; transition: width 2s; height: 130%; ">
<div class="main" style="height: 100%;">
<div class="sidebar">
// menu items
</div>
<div class="header_space"></div> // I used this but it's now working good with precentages..
<img src="banner.png" id="mob-banner"/> // this is the banner
<div class="dynamicPage">
// content of the page..
</div>
</div>
</div>
</body>
</html>
The CSS code:
/******************/
/*** MOBILE ******/
/****************/
.header_space{
display: none;
height: 5.1%;
}
#mob-menu-btn{
display: none;
}
.sub-menu{
display: none;
}
#mob-home-btn{
display: none;
}
#mob-logo{
display: none;
}
#mob-banner{
display: none;
}
.makeFixed{
position: fixed;
}
/*****************************************************************/
#media (max-width: 604px) {
.main{
width: 100%;
/*overflow: hidden;*/
overflow-x: hidden;
}
.sidebar{
float: initial;
width: 100%;
padding: 0;
position: fixed;
z-index: 100;
background-image: url('top_background.png');
text-decoration: none;
}
.header_space{
display: inherit;
height: 4.7%;
}
.sports{
/*display: none;*/
padding: 0 ;
background-color: #fff;
margin: 0;
width:100%;
}
.list{
width: 100%;
overflow: hidden;
overflow-y: auto;
top: -10%;
overflow: hidden;
overflow-y: auto;
height: 880%;
display: none;
}
.sports li{
list-style-image:none;
list-style-type: none;
border-bottom: 2px solid #eeeeee;
margin-bottom: 0px;
margin-left: 0px;
/*padding-top: 15px;
padding-bottom: 15px;*/
padding-left: 10px;
width:100%;
font-family: arial;
text-decoration: none;
overflow: hidden;
/*height: 27px;*/
z-index: 100;
}
.sports a li {
text-decoration: none;
}
.sports2{
display: none;
margin-bottom: 0;
overflow: hidden;
}
.sub-menu{
display: inherit;
float: left;
cursor: pointer;
width: 30px;
/*margin-right: 20px;*/
position: relative;
bottom: 7px;
z-index: 900;
position: relative;
top: 7px;
padding-right: 17px;
}
.sports2 li{
list-style-image:none;
list-style-type: none;
border-bottom: 0px solid #eeeeee;
margin-bottom: 0px;
margin-left: 0px;
/*padding-top: 15px;
padding-bottom: 15px;*/
padding-left: 0px;
width:100%;
font-family: "arial";
text-decoration: none;
overflow: hidden;
}
.sports2 div{
padding: 15px 0;
}
#mob-menu-btn{
float: right;
width: 10%;
display: inherit;
cursor: pointer;
margin-top: 0.8%;
}
#mob-home-btn{
display: inherit;
cursor: pointer;
margin-top: 0.8%;
width: 10%;
float: left;
}
#mob-logo{
display: inherit;
text-align: center;
margin: 0.2% auto;
width: 30%;
}
#mob-banner{
display: inherit;
}
.banner{
display: none;
}
.content{
width:100%;
background-color: white;
}
.logo{
padding-top: 1px;
}
#cat-header{
display: none;
}
.line{
display: none;
}
.table {
width: 100%;
}
#top-pages{
display: none;
}
.top-pages{
display: none;
}
.category-link{
float:left;
padding-top: 25px;
width: 510px;
padding: 15px 0;
}
.content h1 {
color:#031c3f;
font-size:24px;
text-align: left;
font-family: "UScoreRGK";
margin-left: 7px;
}
.content p {
margin-left: 10px;
margin-right: 10px;
}
#active_line{
margin-left: 10px;
margin-right: 10px;
}
#menu {
z-index: 0;
top: 0px;
position: absolute;
/*right: 0px!important;
left: auto!important;*/
}
#menu li {
list-style: none!important;
}
}
#media (min-width : 414px) and (max-width : 533px) {
.category-link{
width: 460px;
}
}
#media (min-width : 375px) and (max-width : 414px) {
.category-link {
width: 340px;
}
.wcmText ul, ol{
margin: 0 0 1em -2.5em;
}
.wcmText p{
margin-top: 0;
}
.wcmText h1, h2{
margin-top: 0;
margin-bottom: 0;
font-size: 110%;
}
}
#media (min-width : 360px) and (max-width : 375px) {
.category-link {
width: 282px;
}
.sidebar{
height: 38px;
}
}
#media (min-width : 320px) and (max-width : 360px) {
.wcmText ul, ol{
margin: 0 0 1em -2.5em;
}
.wcmText p{
margin-top: 0;
}
.wcmText h1, h2{
margin-top: 0;
margin-bottom: 0;
font-size: 110%;
}
}
#media (min-width : 240px) and (max-width : 320px) {
.sidebar{
background-image: url('top_background-320-2.png');
height: 52px;
}
#mob-menu-btn {
width: 7%;
margin-top: 4.8%;
margin-right: 4%;
}
#mob-home-btn {
width: 7%;
margin-top: 4.8%;
margin-left: 4%;
}
#mob-logo {
margin: 2% auto;
width: 45%;
}
.header_space {
height: 52px;
}
.list {
width: 99.5%;
overflow: hidden;
overflow-y: auto;
top: -9%;
overflow: hidden;
overflow-y: auto;
height: 803%;
}
.sports li {
width: 96%;
}
.content h1 {
color:#031c3f;
font-size:24px;
text-align: left;
font-family: "UScoreRGK";
margin-left: 7px;
}
.content p {
margin-left: 10px;
margin-right: 10px;
}
.category-link{
float:left;
padding-top: 25px;
width: 230px;
padding: 15px 0;
}
}
It looks like the only thing you are missing to make the ".header_space" work is to add
style="height: 100%;" to your HTML tag
<html style="height: 100%;">
or in your CSS
html { height:100% }
all your height properties, for example "height:100%" on the BODY tag, are not working.
although, i don't think your solution is an elegant one.
I would prefer to add
#media (max-width: 604px) {
/* lets say 50px is the height of your mobile menu */
#mob-banner { margin-top: 50px; }
}
to the the media query that handles your mobile views, instead of
<div class="header_space"></div>
I realise i have posted couple of questions on floating , nearly near just have one more question on the nth term..
I am trying to adjust some responsive floats using the nth term and widths but im struggling to change the following.
When you reduce the screen size to under 600px i need the two boxes to be displayed as 3 equally boxes, not two. I am struggling to accomplish this using widths and use of nth term.
Im trying to achieve the following.
4 boxes above 900px +px
3 boxes above 600px - 900px
2 boxes 460px - 600px
1 box 0- 460px
If anyone could help it would be great.
http://jsfiddle.net/sFApC/
.display-box{
position: relative;
clear: left;
background: #fff;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.09);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.09);
box-shadow: 0 1px 2px rgba(0,0,0,0.09);
padding: 10px 10px 30px 10px;
border: 1px solid #d1d1d1;
}
.display-box:hover{
-webkit-box-shadow: 0 10px 6px -6px #b5b5b5;
-moz-box-shadow: 0 10px 6px -6px #b5b5b5;
box-shadow: -1px 1px 11px 2px #b5b5b5;
cursor: pointer;
border: 1px solid #c6c6c6 ;
}
.display-user{
max-width: 20px !important;
margin-bottom: 10px;
float: left;
}
.user-name{
float: left;
font-weight: bold;
margin: 6px 0 0 6px;
}
.content-upload img{
height: 20%;
}
#upload-container {
width: 100%;
max-width: 970px;
margin: 0 auto;
margin-top: 20px;
}
#upload-container ul {
width: 100%;
*zoom: 1;
}
#upload-container ul li {
float: left;
margin-right: -100%;
width: 93%;
}
#upload-container ul li a:hover {
text-decoration: none;
}
#upload-container ul li span {
font-size: 16px;
line-height: 22px;
display: block;
padding-bottom: 30px;
}
#upload-container ul li img {
width: 100%;
}
#upload-container ul li:nth-child(1n+1) {
margin-left: 0%;
margin-bottom: 5.85%;
clear: both;
overflow: hidden;
*zoom: 1;
}
#media screen and (min-width: 460px) {
#upload-container ul li {
float: left;
margin-right: -100%;
width: 42.08%;
}
#upload-container ul li span {
padding-bottom: 10px;
}
#upload-container ul li:nth-child(2n+1) {
margin-left: 0%;
margin-bottom: 3.85%;
clear: both;
overflow: hidden;
*zoom: 1;
}
#upload-container ul li:nth-child(2n+2) {
margin-left: 51.93%;
margin-bottom: 3.85%;
clear: none;
}
}
#media screen and (min-width: 600px) {
#upload-container ul li {
float: left;
margin-right: -100%;
width: 45.08%;
}
#upload-container ul li span {
padding-bottom: 10px;
}
#upload-container ul li:nth-child(2n+1) {
margin-left: 0%;
margin-bottom: 3.85%;
clear: both;
overflow: hidden;
*zoom: 1;
}
#upload-container ul li:nth-child(2n+2) {
margin-left: 51.93%;
margin-bottom: 3.85%;
clear: none;
}
}
#media screen and (min-width: 900px) {
#upload-container ul li {
float: left;
margin-right: -100%;
width: 20.8%;
}
#upload-container ul li span {
padding-bottom: 0px;
}
#upload-container ul li:nth-child(4n+1) {
margin-left: 0%;
margin-bottom: 3.85%;
clear: both;
overflow: hidden;
*zoom: 1;
}
#upload-container ul li:nth-child(4n+2) {
margin-left: 25.96%;
margin-bottom: 3.85%;
clear: none;
}
#upload-container ul li:nth-child(4n+3) {
margin-left: 51.93%;
margin-bottom: 3.85%;
clear: none;
}
#upload-container ul li:nth-child(4n+4) {
margin-left: 77.89%;
margin-bottom: 3.85%;
clear: none;
}
}
In #media screen and (min-width: 600px) query you have only 2 columns specified.
Quick fix:
#media screen and (min-width: 600px) {
#upload-container ul li {
float: left;
margin-right: -100%;
width: 27.73%;
}
#upload-container ul li span {
padding-bottom: 10px;
}
#upload-container ul li:nth-child(3n+1) {
margin-left: 0%;
margin-bottom: 3.85%;
clear: both;
overflow: hidden;
*zoom: 1;
}
#upload-container ul li:nth-child(3n+2) {
margin-left: 34.29%;
margin-bottom: 3.85%;
clear: none;
}
#upload-container ul li:nth-child(3n+3) {
margin-left: 68.59%;
margin-bottom: 3.85%;
clear: none;
}
}
This is not pixel-perfect, but you can see 3 columns. You must just adjust margins and widths.
Working sample: http://jsfiddle.net/Ls8c6/1/
Your css is incorrect, you are using the same thing for media screen with min-width:460 and media screen with min-width: 600.
Try to change your code, use this snippet for media screen and min-width of 600px:
#media screen and (min-width: 600px) {
#upload-container ul li {
float: left;
margin-right: -100%;
width: 25.8%;
background-color: green;
}
#upload-container ul li span {
padding-bottom: 0px;
}
#upload-container ul li:nth-child(3n+1) {
margin-left: 0%;
margin-bottom: 3.85%;
clear: both;
overflow: hidden;
*zoom: 1;
}
#upload-container ul li:nth-child(3n+2) {
margin-left: 30.96%;
margin-bottom: 3.85%;
clear: none;
}
#upload-container ul li:nth-child(3n+3) {
margin-left: 61.93%;
margin-bottom: 3.85%;
clear: none;
}
}
I would rather skip the #media queries and just use float: left on .display-box. Together with a width: 200px, you would get roughly the expected behaviour.
.display-box {
float: left;
width: 200px;
}
This would need some margin and padding adjustments, of course. See modified JSFiddle
If you want exactly the given columns, I would still use float: left, but simplify the media queries to just give a relative width for .display-box and refactor the rest into the common CSS rules
.display-box {
float: left;
min-width: 200px;
width: 80%;
}
#media screen and (min-width: 460px) {
.display-box {
width: 40%;
}
}
#media screen and (min-width: 600px) {
.display-box {
width: 25%;
}
}
#media screen and (min-width: 900px) {
.display-box {
width: 17%;
}
}
JSFiddle