Media Query Not Responding Below (max-width: 568px) - css

I'm new to using media queries, and I've got some working but others aren't (and I can't explain why!) First of all, the site in question is at http://thermal-lab.com. I'm trying to have the logos in the top grey banner resize once below 700px width (which is working) and then resize again at 515px width (which is working).
BUT, I also wanted to double the height of the grey footer bar (called second-footer) at 700px, which isn't working. Any help would be very much appreciated!
This is the relevant CSS:
.second-footer {
width:100%;
height:35px;
position:fixed;
bottom:90px;
left:0;
background:#f6f6f6;
border-top:1px solid #c6c6c6;
border-bottom:1px solid #c6c6c6;
}
.second-footer-wrapper span {
display: inline-block;
}
.second-footer-wrapper {
max-width: 980px;
height: 35px;
margin:0 auto;
padding:0 12px;
}
.second-footer-font {
}
.second-footer-wrapper .left {
position: relative;
float: left;
}
.second-footer-wrapper .right {
position: relative;
float: right;
}
This is the code in my media query for 700px:
#media screen and (max-width: 700px) {
.wrapper .ut {
width:185px;
padding-top:4px;
}
.wrapper .csd {
width:65px;
padding-top:3px;
}
.wrapper .utsoa {
width:186px;
padding-top:2px;
}
.second-footer {
height:70px;
}
.second-footer-wrapper {
height: 70px;
}
}

So with what you have provided for code. The first thing I could suggest would be to make sure that all of the .second-footer css is inside the media query brackets. like so:
#media screen and (max-width: 700px) {
/* SECOND FOOTER */
.second-footer {
width:100%;
height:35px;
position:fixed;
bottom:90px;
left:0;
background:#f6f6f6;
border-top:1px solid #c6c6c6;
border-bottom:1px solid #c6c6c6;
}
.second-footer-wrapper span {
display: inline-block;
}
.second-footer-wrapper {
max-width: 980px;
height: 35px;
margin:0 auto;
padding:0 12px;
}
.second-footer-font {
}
.second-footer-wrapper .left {
position: relative;
float: left;
}
.second-footer-wrapper .right {
position: relative;
float: right;
}
/* OTHER STUFF */
.wrapper .ut {
width:185px;
padding-top:4px;
}
.wrapper .csd {
width:65px;
padding-top:3px;
}
.wrapper .utsoa {
width:186px;
padding-top:2px;
}
.second-footer {
height:70px;
}
.second-footer-wrapper {
height: 70px;
}
}
please try that. Also I did not account for any CSS that will overwrite itself. The height would never reach 35px in this example.
.second-footer {
width:100%;
height:35px;
position:fixed;
bottom:90px;
left:0;
background:#f6f6f6;
border-top:1px solid #c6c6c6;
border-bottom:1px solid #c6c6c6;
}
.second-footer {
height:70px;
}

This is all about selector strength and specificity. A rule being defined within a media query does not give it greater specificity. Since your media query stylesheet appears earlier in the document, it has lower specificity.
Here are two ways you can correct that:
Move your media query stylesheets later in the document.
Increase the specificity of the selectors in your media query rules.
This can be as simple as changing the selector for the media query rules to any of the following:
html .second-footer
div.second-footer
* .second-footer
Give a man a fish vs Teach a man to fish
This problem was simple to solve. Here's how I did it:
Open thermal-lab.com in a browser with a width less than 700px.
Hit F12 to open up developer tools. This works in any browser except FireFox without FireBug. F12 opens FireBug, but you have to install that separately. To open FireFox's built-in developer tools, use the menu.
Locate the element in source whose style is not being applied as expected.
Look at the style inspector for that element.
Notice that the height definition in the media query rule has been struck? This tells you that the element did match the rule, but a rule with greater specificity also defined height. Notice the default rule lists height as well. The lack of strikethrough tells us that this is the rule that was applied.
Both rules have the same selector. The tie breaker for rule specificity is document order. Rules appearing later in the document have higher specificity.

Related

CSS: Centering elements vertically

I'm trying to develop my first responsive website but I'm having some trouble (of course).
I need an element (sort of a menu) to contain 4 row of elements and each element has an image to the left and some text to the right. Now, the issue I'm having is that I can't seem to be able to make the elements center vertically correctly. I've tried several methods that seem to work for a lot of people so I thought I'ld ask if anybody knows why nothing seems to work for me.
This is what the image CSS looks like:
.tablaBuscadorElementos > img {
position: relative;
width: 20px;
height:20px;
left:0;
right:0;
top:0;
bottom:0;
margin:0 auto;
float:left;}
Here is the fiddle: http://jsfiddle.net/mampy3000/9JZdZ/1/
Appreciate any help!
since your elements are inline-block , you can inject an inline-block pseudo-element 100% height and vertical-align:middle it to img and span : DEMO
basicly (+ below update of your CSS):
.tablaBuscadorElementos:before {
content:'';
height:100%;
display:inline-block;
vertical-align:middle;
}
.tablaBuscadorElementos {
height:22%;/* instead min-height so value can be used for pseudo or direct child */
border: 1px solid black;
padding:0px;
width:100%;
}
.tablaBuscadorElementos > span {
font-size:20px;
width:80%;
vertical-align:middle; /* align to next inline-block element or baseline*/
border:1px solid black;
display:inline-block;/* layout*/
}
.tablaBuscadorElementos > img {
vertical-align:middle; /* align to next inline-block element or baseline*/
width: 20px;
height:20px;
}
.tablaBuscador, .tablaBuscadorElementos{
display:block;
}
.tablaBuscadorElementos:before {
content:'';
height:100%;/* calculated from 22% parent's height */
display:inline-block;/* layout*/
vertical-align:middle;/* align to next inline-block element or baseline*/
}
You can do this by adding this css to .tablaBuscador
position: fixed;
top: 50%;
margin-top:-100px; /* half of height */
More info here: How to center a table of the screen (vertically and horizontally)
The newer option would be to use calc() but you might run into browser support issues.
position: fixed;
top:calc(50% - 100px).
Here are which browsers support calc(): http://caniuse.com/#feat=calc
Your code needs a major tune-up. You are floating elements, using vertical-align on them, positioning them relatively with left, right, top, and bottom set to 0. None of these make any sense. Here's a cleaned up fiddle: http://jsfiddle.net/jL2Gz/.
And here's a tuned up code:
* {
padding: 0;
margin: 0;
}
body {
height:100%;
}
.tablaBuscador {
font-family: "Maven Pro", sans-serif;
height:200px;
width:40%;
}
.tablaBuscador > div {
border: 1px solid black;
padding: 10px 0;
}
.tablaBuscador > div > span {
font-size:20px;
width:80%;
border:1px solid black;
}
.tablaBuscador > div > img {
width: 20px;
height: 20px;
}
.tablaBuscador > div > * {
display: inline-block;
vertical-align: middle;
}

Can't get div to disappear on resizing

I'm trying to get a div to disappear using
#media all and (max-width:1000px) {
#triangle{ display: none; }
}
but it's not working for me for some reason. This is the CSS of the div:
#triangle {
width: 0;
height: 0;
position:absolute;
top:110px;
right:250px;
border-bottom: 100px solid #d8e2ff;
border-left: 100px solid transparent;
border-top-right-radius: 0%;
display:inline-block;
}
Here is the website : http://www.ciaransmith.ie/aboutme.php. The div is the triangle of the speech bubble
Any ideas?
Also, my contact page is displaying wonky sometimes, and other times it displays fine, why is this happening?
Try this
#media all and (max-width:1000px) {
#triangle{
display: none !important;
}
}
Please place the code in the file itself not in CSS file
I could only find this:
#media all and (max-width:1000px) {
#whiteback { display: none; }
}
Which targets the wrong ID. Perhaps I missed the correct css but either way style isnt being aplied so the current issue is either the ID, or the media syntax
display: inline-block; isn't wrapped in a media query. Add this:
#media all and (min-width: 1001px) {
#triangle {
display: inline-block;
}
}

How can I make text in a div tag responsive?

I've got basic web design skills atm, I'm working on my portfolio and need help with the landing page please.
I want the heading and sub heading on my page to resize when the browser resizes, but it's not working.
The body font is 12px but I only want the font to resize in the div tags not the body text.
I have 2 div tags with ID tags for the CSS like so.
<div id="heading">
this is my heading text
</div>
<div id="subheading">
this is my subheading text
</div>
This is the css.
#heading {
float: left;
width: 100%;
padding-top: 3%;
padding-bottom: 1%;
font-size: 55px;
color: #FFF;
position: relative;
}
#subheading {
float: left;
width: 100%;
padding-top: 3%;
padding-bottom: 3%;
font-size: 36px;
position: relative;
}
I want both headings to reduce in size by about 20/30% when the window/browser is resized
but when I change the values for the tablet css, different to these values in the desktop view
everything changes straight away. I want the text to stay the same in desktop view and only change size in tablet view. Hope this makes sense.
Appreciate a reply.
Use Media Queries
For Instance,
#media only screen and (min-width: 1920px) {
#heading {
float:left;
width:100%;
padding-top:3%;
padding-bottom:1%;
font-size:55px;
color:#FFF;
position:relative;
font-size: xxpt; /*put your size here*/
}
#subheading {
float:left;
width:100%;
padding-top:3%;
padding-bottom:3%;
font-size:36px;
position:relative;
font-size: xxpt; /*put your size here*/
#media only screen and (min-width: 1024px) /* for ipad */ {
#heading {
float:left;
width:100%;
padding-top:3%;
padding-bottom:1%;
font-size:55px;
color:#FFF;
position:relative;
font-size: xxpt; /*put your size here*/
}
#subheading {
float:left;
width:100%;
padding-top:3%;
padding-bottom:3%;
font-size:36px;
position:relative;
font-size: xxpt; /*put your size here*/
}
PS: The pixel values are used as an approximation for illustrative purposes. You can replace them with your desired values.
See a working example of a media query here:
http://jsfiddle.net/fSYSJ/
body { background:silver; }
#heading {
float:left;
width:100%;
padding-top:3%;
padding-bottom:1%;
font-size:55px;
color:#FFF;
position:relative;
}
#subheading {
float:left;
width:100%;
padding-top:3%;
padding-bottom:3%;
font-size:36px;
position:relative;
}
#media screen and (max-width: 768px)
{
#heading { color:red; }
#subheading { color:red; }
}
#media screen and (max-width: 420px)
{
#heading { color:blue; }
#subheading { color:blue; }
}
Notice I'm currently just changing the color of the headings, just adjust it to change the size instead and also adjust the break points in pixels to your liking.
Don't set the width to 100% ever ! Even better - remove the width and it will work ;d
#heading {
padding-top:3%;
padding-bottom:1%;
font-size:55px;
color:#FFF;
position:relative;
}
becouse the div is a BLOCK element, it will take all the space in X axis, so you dont have to set the width property. By default its 100% ;)

Background wont reach bottom of page

I have a white container on top of the bg but it stops even though min-height is set as 100%, heres the CSS for this container and in bottom I have included image of what happens when I scroll to the bottom:
Container where post is:
Yellow Bg:
.home-body {
background-color:#EAC117;
height: 100%;
.home-main-content {
width:800px;
min-height: 100%;
position:absolute;
overflow:hidden;
margin-left:56.5%;
left:-500px;
top:51px;
border-left:1px solid black;
border-right:1px solid black;
background-color:#fff;
background-repeat:repeat-y;
.home-post-echoed-container {
width:400px;
position:absolute;
margin-left:50%;
left:-200px;
top:200px;
overflow:hidden;
}
.home-echoed-posts {
width:600px;
overflow:hidden;
left:-98px;
position:relative;
background-color:#fff;
margin-bottom:-5px;
border-top:1px solid;color:#0a527e;
border-left:1px solid;color:#0a527e;
border-right:1px solid;color:#0a527e;
}
.home-echoed-posts-post {
margin:10px;
color:black;
}
.home-echoed-posts-email {
margin:10px;
color:black;
}
.home-echoed-posts-date {
margin:10px;
color:black;
}
You are doing it wrong.
To center something you should use (instead of absolute positioning):
.foobar{
margin: 0 auto;
width: 800px;
}
As for "why comments are not expanding the container", it is hard to guess without code, but there are two reasonable possibilities: positioning or floats. There nothing i can do about it. But if they are floated, then easies is to have container with following css:
.container{
overflow: hidden;
}
It is a bit counter-intuitive, but works like charm. You can read more about it here.
Update: and read this article too.
Update 2:
Looks like it is the worts case scenario. You are using positioning .. for everything. YOu really need to learn how to use floats.
.home-post-echoed-container {
width: 600px;
margin: 0 auto;
padding-top: 200px; // im guessing what top:200px was doing
overflow:hidden;
}
.home-echoed-posts {
width:600px;
float: left;
background: #fff;
margin-bottom: -5px;
border: 1px solid #0a527e;
border-bottom: 0;
}
Something like this. But I'm really just guessing.
html, body
{
height:100%;
}
Make sure you include that in the top of your CSS script, else setting .home-main-content to min-height:100%; won't work, because to CSS, if undefined elsewhere, 100% is simply the height of the current div.
Also ensure that you have that same property set if your .home-main-content is surrounded by another div.

Div not coming to front: Z-Index

I am using the code below, but .under is not rising above (and covering up) #portfolio_content .img img as it should on hover.
#portfolio_wrap {
overflow:hidden;
width:980px;
float:left
}
#portfolio_content {
float:left;
clear:both;
margin:0 auto;
overflow:hidden;
width:650px!important
}
#portfolio_content ul {
list-style:none
}
#portfolio_content .img a { }
#portfolio_content .img a:hover { }
#portfolio_content .img {
display:block;
float:left;
height:210px;
margin:0 35px 35px 0!important;
overflow:hidden;
padding:0;
width:307px
}
#portfolio_content .img img {
display:block;
position:absolute!important;
overflow:hidden;
z-index:3!important
}
#portfolio_content .img .title, #portfolio_content .img .title a {
font-size:22px;
margin:100px 0 10px 0;
float:left!important;
width:307px;
text-align:center;
position:relative
}
.desc {
font-size:13px;
display:block;
text-align:center!important;
margin:0 auto!important;
width:307px
}
.under {
z-index:2!important;
display:inline;
position:absolute;
width:307px;
height:210px
}
.under:hover { z-index:4!important }
Any thoughts? I am assuming this is related to z-index, but I don't know what I have done wrong.
Without seeing the page rendered, I would have to assume the problem is that you cannot actually hover over .under (z-index:2) as it is hidden under the #portfolio_content .img img (z-index:3) initially and therefore you would just be hovering the img instead.
You cannot hover over .under since it's always "under" your images, tw16 is right.
Instead of playing with z-indexes, try actually placing .under inside .img but on top of your images and with display:none, and then do something like :
.img:hover .under{
display:block;
}
I might add your markup isn't quite optimized and .img should be directly placed on the a tags, not on useless inside spans, which are waaaay too many anyway :)
Edit : (as answer to comment)
In case there is no image to show, your markup will be different (as i suppose generated by a server side script, like php) as when there is one to display (for instance you won't echo the img tag).
You can as well use that condition to write 2 differents classes, for instance .img and .no-img :
.no-img .under{
display:block;
}
.img .under{
display:none;
}
.img:hover .under{
display:block;
}

Resources