This is my first question over here, I searched the site but I really couldn't find a decent answer. My problem is pretty specific.
On full resolution my homepage consists of four columns, however, when the window-width gets below 960, it transforms in to two columns, this is the code I used:
The HTML:
<div class="columns">
<div class="begin col14">
<h2>Title</h2>
Content
</div>
<div class="begin col14">
<h2>Title</h2>
Content
</div>
<div class="begin col14">
<h2>Title</h2>
Content
</div>
<div class="begin col14">
<h2>Title</h2>
Content
</div>
</div>
The CSS:
#media all and (max-width: 960px) {
.begin {
width:46%;
margin:0px 2% 2em 2%;
float:left;
}
}
The problem is only showing on a browser-width of around 619px, then the first column on the second row jumps to the next row.
For an example, please check: www.visiamedia.nl
I hope someone can help me out, it really bothers me.
Greetings
That's because your boxes are different heights when resized - and first one is pushing other floats aside. You could potentially fix the issue by setting a media query with a specific height between about 515px to 640px:
#media all and (min-width: 515px) and (max-width: 640px) {
.begin {
height: 190px;
}
}
That's because you have a width of 46%. Change it to 21%
#media all and (max-width: 960px) {
.begin {
width:21%;
margin:0px 2% 2em 2%;
float:left;
}
}
Related
I got media queries working perfect on second html page with this code
#media only screen and (min-device-width: 200px) and (max-device-width: 1099px) {
.snebild img {
width: 50%;
max-width: 50%;
right: 2%;
}
.title {
margin-left: 4%;
position: absolute;
top: 10%;
}
}
But on my second page im trying to change the font size so it looks good on lower resolutions but using same code just changing to correct class and p element but nothing works.
#media only screen and (min-device-width: 200px) and (max-device-width: 1099px) {
.introus p {
font-size: 8px;
}
}
This is the HTML
<div class="introus">
<h2>Main Title</h2>
<h4>Second title</h4>
<p>Text to change size on when using lower resolution such as Iphones</p>
</div>
I assume you are testing it on a desktop device and not on a mobile device.
Try to change min-device-width to min-width that should work.
Correct me if I'm wrong.
You should use min-width instead of min-device-width because the main difference between width and device-width is that device-widths don’t always match the layout viewport of said device.
Changing that parameters the code works fine
#media only screen and (min-width: 200px) and (max-width: 1099px) {
.introus p {font-size: 8px;}
}
<div class="introus">
<h2>Main Title</h2>
<h4>Second title</h4>
<p>Text to change size on when using lower resolution such as Iphones.</p>
</div>
I have this div column in a content row:
<div class="col-md-4 no-gutter" style="float: right;">
<div class="well">
<p>blah blah blah (content) </p>
</div>
</div>
I am using a CMS (Cascade Server) with Bootstrap 2.
This worked to remove the gutter padding...
[class*='col-'].no-gutter {
padding-right:0;
padding-left:0;
}
...but upon looking at it in desktop view, I need some padding for screens over 992px wide so that the text doesn't run up to the div column. I tried adding the following but I think my sytax is wrong and I don't know how to fix it. Can someone help me?
#media screen and (min-width: 992px) and [class*='col-'].no-gutter {
padding-right:0;
padding-left:15;
}
Quantastical is correct about the formatting... another minor issue, you're also missing px on the end of the padding-left. With 0 you don't need it but with other values you'll need px, em, % specified
#media screen and (min-width: 992px) {
[class*='col-'].no-gutter {
padding-right:0;
padding-left:15px;
}
}
You #media syntax is wrong. It needs to surround your CSS declarations like so:
#media screen and (min-width: 992px) {
[class*='col-'].no-gutter {
padding-right: 0;
padding-left: 15px;
}
}
See the W3 documentation on Media Queries for more information on how to use them.
Edit: Add units to padding-left per Kyle Larson's answer No sense promoting poor code.
I have two columns, first column has an image, second is the article. The article has a ton of "Empty spaces" I would like the height of the article to be the same height as the image so there's not visible empty space.
<article>
<div class="row">
<div class="row-sm-height">
<aside class="col-sm-6 ">
<img src="http://i0.wp.com/www.sooziq.com/wp-content/uploads/2015/11/32.jpg?resize=270%2C200" />
</aside>
<aside class="col-sm-6">
<div>
<span> Basketball</span>
<h2 id="H2_2">
What really Matters
</h2>
<span id="SPAN_2">November 12, 2015</span>
<p>
Make sure you load up on the fluids and snacks and use the washroom because these are the top 3 things to watch for in basketball! Read More
</p>
</div>
</aside>
</div>
</div>
</article>
Demo
http://codepen.io/anon/pen/WQVxor
I would like it to also be responsive, I can get the height to match using trial and error but I don't think that's the right approach.
The most simple and maybe also the best solution in your case is to make the 2 columns' parent div have the same background color as the 2 columns do so it looks like the article column has expanded.
In your css, find .row-sm-height under #media (min-width: 768px) and add the background color:
.row-sm-height {
display:table-row;
background: #f7f7f7;
}
And you just need to do nothing about specifying any height. It just adjusts to your image height.
Assuming that your images will be the same size one the same device you can set the min-height.
Add a new class to the div that is your article (not the one with "col-x").
Set the class to have a min-height of Npx.
As an example for your CSS:
div.image-article {
min-height: 250px;
}
If making it responsive you probably have your images smaller on different devices. Use a media query for these.
div.image-article {
#media (min-width: 0) {
min-height: 250px;
}
#media (min-width: #screen-xs-min) {
min-height: 250px;
}
#media (min-width: #screen-sm-min) {
min-height: 275px;
}
#media (min-width: #screen-md-min) {
min-height: 290px;
}
#media (min-width: #screen-lg-min) {
min-height: 320px;
}
}
On a full sized screen, I have three images in a column format that should, all together, take up the entire screen. Right now, my code works, in that the the images take up the width of the screen and on screen less than 600px, the images stack one top of one another. But the issue is that the images are not taking up the entire width. The code is below and I am using a sample pic that is huge, but it still doesn't show the entire height of the image.
EDITED TO TAKE OUT MY ORIGINAL CODE
Okay, per comments, I have changed the code to look: http://jsfiddle.net/zx11x99x/
.wrapper img{
float:left;
width:100%;
}
#media screen and (min-width: 600px) {
.wrapper img{
width:33%;
}
}
<div class="wrapper">
<img src="https://recodetech.files.wordpress.com/2014/05/early-vehicle-lores.jpg?quality=80&strip=info" alt="">
<img src="https://recodetech.files.wordpress.com/2014/05/early-vehicle-lores.jpg?quality=80&strip=info" alt="">
<img src="https://recodetech.files.wordpress.com/2014/05/early-vehicle-lores.jpg?quality=80&strip=info" alt="">
</div>
The problem is still that the images are not full screen, which I cannot seem to figure out.
In short, I am trying to go for this, but with the columns stacking on mobile
http://jsfiddle.net/9udg7qxg/
example example example example example example example example example http://jsfiddle.net/zx11x99x/
code
Updated:
* { padding: 0; margin: 0; }
#media (max-width:1400px) and (min-width:600px) {
.wrapper > img{
float:left;
max-width:33%;
}
}
#media (max-width:600px) and (min-width:100px) {
.wrapper > img{
width:100%;
display:block;
}
}
JSFIDDLE
Just also make sure you use the correct Meta tag.
I have two floating <div>'s .a and .b.
Both <div>'s are floated to left, So that they both are aligned horizontally with 50% width for each.
But on small screen I want both <div>'s to be aligned vertically with full width but second <div> .b must appear first and first <div> .a must appear under <div> .b.
Also I can't set height on both <div>'s since their content is dynamic.
Following is sample code:
.a{width:50%; float:left;background-color:#CCCCCC}
.b{width:50%; float:left; background-color:#FFC;}
#media only screen and (min-width: 320px) and (max-width: 480px) {
.a{width:100%; float:left; background-color:#CCCCCC}
.b{width:100%; float:left; background-color:#FFC;}
}
<div class="a">This is first div</div>
<div class="b">this is Second div</div>
fiddle demo
Invert the HTML order:
<div class="b">this is Second div</div>
<div class="a">This is first div</div>
use float:right initially:
.a{width:50%; float:right; background:#ccc}
.b{width:50%; float:right; background:#ffc;}
#media only screen and (min-width: 320px) and (max-width: 480px) {
.a{width:100%; float:left;}
.b{width:100%; float:left;}
}
Alright, let's get into it. You want them to be left aligned in large resolutions, but inverted in mobile resolutions.
Mobile version: Let's take a mobile-first approach. This means we will support the mobile styles as the default, and include large-screen styles in the media query. It seems much simpler and more reasonable, since your divs can be static in that case. Then, it makes a lot more sense to have the second div come first.:
<div class="section">Second div</div>
<div class="section">First div</div>
Then, there's not much to style, just regular simple css for the mobile version. Mainly this:
.section {
background-color: #f2f2f2;
}
Check an example here: http://jsfiddle.net/arthurcamara/3yv2urkm/
Large screen version: I also took the freedom to make the code more semantic. So I added separate classes lg-right and lg-left to the divs:
<div class="section lg-right">Text, second div</div>
<div class="section lg-left">Text, first div </div>
Now it comes to adding your media query.
#media only screen and (min-width: 481px) {
.section {
width: 50%;
}
.lg-right {
float: right;
}
.lg-left {
float: left;
}
}
See final working version here: http://jsfiddle.net/arthurcamara/3yv2urkm/2/
Also, you might want to consider using a framework such as Foundation. They already provide this functionality in a much broader and flexible way then the one I presented.
You can use the order property of CSS3 flexbox module as follows:
HTML:
<div class="flex-parent">
<div class="flex-child a">This is first div</div>
<div class="flex-child b">this is Second div</div>
</div>
CSS:
.flex-parent {
display:flex;
flex-wrap: wrap;
width:100%;
}
.flex-child {
flex:1;
}
.a {
background-color: #CCCCCC
}
.b {
background-color: #FFC;
}
#media only screen and (min-width: 320px) and (max-width: 480px) {
.flex-child {
flex-basis:100%;
}
.a {
order:2;
}
.b {
order:1;
}
}
JSFiddle Demo
flexbox browser support# caniuse