Change the float of 2 div on mobile - html

I have two main div on my site, a left and a right.
The left one has these classes: col-md-3 left_side
And the right one: col-md-9 right_side
In the CSS file, the left_side and the right_side classes have only just some padding, no float. The floating is from the col-md bootstrap classes.
How can I do that if I am viewing the site on mobile or tablet, to change these to divs sequence? The right_side div will be the first.
I want this, because now on mobile, the left_side div is the first, and I have to scroll down a lot to view the actual page content or the product page I selected.
Update: Whit this code, i still get the same problem.
#media (max-width: 575px) {
.left_side {
float: right;
}
.right_side {
float: left;
}
}
#media (min-width: 576px) and (max-width: 767px) {
.left_side {
float: right;
}
.right_side {
float: left;
}
}
#media (min-width: 768px) and (max-width: 991px) {
.left_side {
float: right;
}
.right_side {
float: left;
}
}

This is a simple solution for this issue:
Edit: changes css
Edit2 Using max-width instead min-width in css media query
.left_side {
background-color: red;
}
.right_side {
float: right !important;
background-color: blue;
}
#media (max-width: 992px) {
.right_side {
float: none !important;
}
}
<div class="col-md-9 right_side">Right in desktop, top in mobile</div>
<div class="col-md-3 left_side">left in desktop, bottom in mobile</div>

Related

Mobile website Navigation & Logo divs overlapping

So I'm trying to make this website mobile friendly: coveartschildcare.com and all the header divs are overlapping and nothing I've tried seems to be working. This is the CSS I'm using:
#media only screen
and (min-device-width: 320px)
and (max-device-width: 568px)
and (-webkit-min-device-pixel-ratio: 2) {
div#logo
{
float: left;
}
div#logo h1
{
font-size: 0.5em;
color: #777;
}
div#logo span
{
font-size: 1.4em;
color: #FFF;
}
div#header
{
background: url(../images/mobile-bg.jpg) no-repeat bottom center;
text-align: center;
float: left;
}
div#nav
{
z-index : 1;
float: left;
position: relative !important;
}
.container
{
float: left;
}
.clear {
clear: both;
}
}
I've tried making positions relative, absolute, floating left or none, auto width & height and nothing works. Any help would be greatly appreciated.
ok, what you are asking is to make the div tags smaller on your page so that they don't overlap?
to do that create a new rule like this one:
#media (max-width: 520px) {
div {
width: 50px;
}
body {
color: blue;
}
}
the max-width is the max-width that the browser will activate this on.
you can create two #media rules and change the second #media rule's max-width to equal a different number. the browser will activate the rule if the width is smaller than the max-width. when the screen size gets smaller than both of the #media rules it will run the smaller one
hope this helps...
I think, if you delte the position: absolute; on the #nav-wrapper{} it is no more overlapping.

Different html code based on screen resolution

Currently I manage the CSS code differently based on screen size using and it works fine:
#media only screen and (max-width: 40em) {
my code
}
Now, what I'm trying to achieve is to have a piece of html code placed differently based on the screen resolution.
For instance my div id="news_box" would be placed in my header wrapper on desktop. Whereas on mobile phones, div id="news_box" would be placed in the footer wrapper.
How could I achieve that?
Many thanks,
As far as I know, there is no way to manipulate the DOM using CSS in that way, but you could use a JavaScript hack:
window.addEventListener('load', function(){
var width = this.innerWidth;
if(width < 400) {
document.getElementById('footer-id').appendChild(document.getElementById('news_box'));
}
});
Or maybe assign a class to it and have the element appear in both the header and footer (although, you would want to change the ID):
#footer-id .news_box {
display: none;
}
#header-id .news_box {
display: block;
}
#media only screen and (max-width: 40em) {
#footer-id .news_box {
display: block;
}
#header-id .news_box {
display: none;
}
}
With this you go through the diffrent resolutions. You have to change the values for your "news_box" for every different one.
e.g. For desktops you have a float:left box which will be not present in the css part for your mobiles.
example:
/* Tablets */
#media only screen and (min-width: 760px) {
#news_box { max-width: 760px }
…
}
/* midle screens */
#media only screen and (min-width: 980px) {
#news_box { max-width: 980px; float:left; margin: 0 auto; }
}
/* big screens */
#media only screen and (min-width: 1280px) {
#news_box { max-width: 1280px; float:left; margin: 0 auto; }
…
}

How to get a fluid height with rows

How can I set a fluid height for each row? The rows would either be 4 or 6 based on the orientation as there are 24 total icons (6x4 or 4x6).
I was able to solve the 4 col and 6 col icon set and have a fluid width. However, I cannot figure out how to get the spacing between rows fluid for the height.
Also, I'm open to suggestions on how to improve the code as well if you think there's a better alternative.
Here's my code:
CSS
#media only screen and (min-width: 320px) and (max-width: 768px) and (orientation: portrait) {
/* Clear 4 columns */
.profile {
display: none;
}
.app {
float: left;
text-align: center;
width: 25%;
}
.clear4 {
clear: both;
}
}
#media only screen and (min-width: 320px) and (max-width: 768px) and (orientation: landscape) {
/* Clear 6 columns */
.profile {
display: none;
}
.apps {
}
.app {
float: left;
text-align: center;
width: calc(100%/6);
}
.clear6 {
clear: both;
}
}
HTML
<div class="apps">
</div><!-- .apps -->
you mean the space between the app divs?
.app {
float: left;
position:relative;
text-align: center;
width: 100%;
margin-bottom:50px;
margin-top:50px;
}
have a look in here fiddle

Fixed size bootstrap container

I am trying to make container fixed size 750px for all sized windows.
Here is HTML:
<div class="container">
<div class="thumbnail" >
..........<br/>
..........
</div>
</div>
and custom CSS:
#media (min-width: 1200px) {
.container {
width: 750px;
}
#media (min-width: 992px) {
.container {
width: 750px;
}
#media (min-width: 768px) {
.container {
width: 750px;
}
But the problem is when I am resizing window from big to small at some point size of thumbnail is getting a little larger and then reverses to its initial size.
Here is a fiddle http://jsfiddle.net/Wy22s/718/ . You can just resize browser window or slide inner window in fiddle itself to left and then to right to reproduce this behavior.
I have tried to add another div with row class. Tried combinations with col-sm, col-md etc, but I can not manage to achieve desired behavior. How can I fix this so the container/thumbnail size stays the same?
you forgot to close the #media brackets.
#media (min-width: 1200px) {
.container {
width: 750px !important;
}
}
#media (min-width: 992px) {
.container {
width: 750px !important;
}
}
#media (min-width: 768px) {
.container {
width: 750px !important;
}
}
.container{ width: 750px !important;}
.thumbnail{ width: 750px !important;}

How to edit css margin-top for a text in mobile version

I want to edit the margin-top of a text in the mobile device. I have come this far but I know there is something crazy in the code:
.Foljoss {
padding-left: 18px;
background: #fff;
}
#media screen and
(max-width: 768px; margin-top:17px)
It is the last part in which I dont get it. How can I adjust the top margin for the <div class="Foljoss"> on the mobile version? Notice that the #media screen-part is not correct.
You need to wrap the css inside a selector inside the media query.
#media screen and (max-width: 768px) {
.Foljoss {
margin-top: 17px;
}
}
body {
background-color: lightgreen;
}
.show-on-mobile {
display: none;
}
#media screen and (max-width: 568px) {
.show-on-mobile {
display: block;
}
.hide-on-mobile {
display: none;
}
body {
background-color: lightblue;
}
}
<div class="show-on-mobile">Only visible when width is <= 568px</div>
<div class="hide-on-mobile">Disappears when screen width > 568px</div>
/* 767 is max for mobile */
#media screen and (max-width: 767px) {
.Foljoss {
margin-top: 17px;
}
}