Media Queries not overriding native styles? - css

I'm wondering why some of my media queries are not overriding the native styles at the view port their being called. I'm trying to restyle a menu responsively, to stack, and have the navigation area's height longer in a WP theme. But every which way I add the specs I create to get this effect via editing Live CSS in Safari or FF inspect element - the styles I insert under the specific viewport I'm targeting are not being read. I know I'm using media queries correctly as it reads NEW styles, just doesn't override native? I'm missing something here? Here's what I'm trying to add that won't read.
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#access li {
    float: none; // To translate to not to float to the left stack
    position: relative;
}
#access {
    background: url("http://testsite.com/wp-content/uploads/2012/01/menu_bg.gif") repeat scroll 0 0 transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    clear: both;
    display: block;
    float: left;
    height: 240px; //Changed the height to allow stack
    width: 100%;
}
Edit: Here's the FULL set of Responsive styles I'm calling, if matters.
/* =Responsive Structure
----------------------------------------------- */
#media (max-width: 800px) {
body {
padding: 0;
}
#page {
margin-top: 0; overflow: hidden;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
#socialpost { margin-left: -100px; }
p {font-size: 12px; }
#sublogo { display: none; }
#footcontain { padding-left: 0;}
#access a {
color: #000000;
display: block;
font-family: arial;
line-height: 3.11em;
padding: 0 20px;
text-decoration: none;
#access a { font-size: 12px; }
#access li {
float: left;
margin-left: -28px;
position: relative; }
}
#media (max-width: 650px) {
/* #media (max-width: 650px) Reduce font-sizes for better readability on smaller devices */
body {
padding: 0;
}
#page {
margin-top: 0;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 12px; }
#sublogo { display: none; }
#access a {
color: #000000;
display: block;
font-family: arial;
line-height: 3.11em;
padding: 0 13px;
text-decoration: none;
font-size: 11px;}
#footcontain { padding-left: 0;}
#access a {
padding: 0 15px; }
}
#media (max-width: 450px) {
#content .gallery-columns-2 .gallery-item {
width: 45%;
padding-right: 4%;
}
#content .gallery-columns-2 .gallery-item img {
width: 100%;
height: auto;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 10px; }
.entry-content, .entry-summary {
padding: 1.625em 0 0;
width: 48%; }
#footcontain { padding-left: 0;}
#branding #s {
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
float: right;
height: 35px;
width: 47px; }
.widget-title { margin-top: 35px; }
.flexslider .slides img {
border: 0 none;
display: block;
max-width: 100%;
padding-bottom: 25px; }
#footcontain { display:none;}
#access li {
float: none;
position: relative;
}
#access {
height: 70px;
}
#access a {
color: #000000;
display: block;
font-family: arial;
font-weight: bolder;
line-height: 3.11em;
padding: 0 10px;
text-decoration: none;
}
#access ul {
font-size: 10px;
list-style: none outside none;
margin: 0 0 0 -80px;
padding-left: 0;
}
.flex-control-nav { display: none; }
.flexslider {
margin: 0 0 67px; }
.flex-caption { display: none; } //Could Display this here, need to make take half of slider
}
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
body { padding: 0; }
#access {
height: 70px;
}
#page {
margin-top: 0; overflow: hidden;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 10px; }
#sublogo { display: none; }
#access a { padding: 0 10px; }
#access li {
float: none;
position: relative;
}
.entry-content, .entry-summary {
padding: 1.625em 0 0;
width: 35%; }
#footcontain { display: none; }
#branding #s {
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
float: right;
height: 35px;
width: 47px; }
#footcontain { display: none; }
.widget-title { margin-top: 35px; } //Attempt to Create Space for Slider Page Nation
#access { height: 70px; }
#access li {
float: none;
position: relative;
}
.flex-control-nav { display: none; }
.flex-caption { display: none; } //Could Display this here, need to make take half of slider, check
.flexslider {
margin: 0 0 67px; }
}

The CSS code from your post is not working because it's a device-specific style and you are viewing it on a Safari, Chrome or Firefox using a laptop/desktop. You are forgetting that Media Queries are giving you the possibility to apply different styles when a page is being displayed in a 'browser' - resized to 480px and on an iPhone (which has a max-device-width of 480px).
Example CSS:
/* max-width */
#media screen and (max-width: 480px) {
.one {
background: #F9C;
}
}
/* min-width & max-width */
#media screen and (min-width: 480px) and (max-width: 900px) {
.two {
background: #9CF;
}
}
/* min-width */
#media screen and (min-width: 900px) {
.three {
background: #F90;
}
}
/* iphone specific css */
#media screen and (max-device-width: 480px) {
.iphone {
background: #ccc;
}
}
In the example above you can target both and still have a separate style for your device of choice. If you want to test it in a browser just use the min-width or max-width properties.
Hope this helps.

On the top example there's a missing closing bracket.
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#access li {
float: none; // To translate to not to float to the left stack
position: relative;
}
#access {
background: url("http://testsite.com/wp-content/uploads/2012/01/menu_bg.gif") repeat scroll 0 0 transparent;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
clear: both;
display: block;
float: left;
height: 240px; //Changed the height to allow stack
width: 100%;
}
}

Related

Admob Native Ad CSS Google Info Button Background Color

How we can change background color of google ads info button from css. We have customized the ad but we cannot change background color of google ad info button. I have seen some native ads that have changed the color, even thoug I delete add every part of the code it doesn't go anywhere so how can I change background color of it? I have added the css code and picture
/* Note: 1px = 1dp in this css */
/* == Colors == */
body {
background-color: #ffffff;
}
.title-link {
color: #000000;
}
.button {
background-color: #9D0000;
}
.button-text,
.button-link {
color: #FFFFFF;
}
.price,
.reviews {
color: rgba(0,0,0,0.5);
}
.reviews svg {
fill: rgba(0,0,0,0.7);
}
.url-link {
color: rgba(0,0,0,0.3);
}
.body {
color: rgba(0,0,0,0.7);
}
/* == Fonts == */
body {
font-family: "Lobster";
font-weight: normal;
font-size: 10px;
}
#media (min-height: 300px) {
body {
font-size: 11px;
}
}
#media (min-width: 360px) and (min-height: 300px) {
body {
font-size: 12px;
}
}
#media (min-width: 700px) and (min-height: 300px) {
body {
font-size: 16px;
}
}
.title {
font-size: 1.1em;
line-height: 1.2em;
}
.button {
font-size: 1.1em;
}
.body,
.price,
.reviews,
.url {
font-size: 1em;
line-height: 1.1em;
}
#media (min-width: 360px) and (min-height: 300px) {
.title {
font-size: 1.2em;
line-height: 1.25em;
}
.button {
font-size: 1.2em;
}
}
#media (min-width: 700px) and (min-height: 300px) {
.title {
font-size: 1.3em;
line-height: 1.35em;
}
.button {
font-size: 1.3em;
}
}
/* == Layout == */
.title {
margin-bottom: 5px;
padding: 5px 0 0 8px;
}
.body {
margin: 2px 8px;
}
.button {
position: absolute;
bottom: 8px;
left: 8px;
}
/* == App install and video ad layouts == */
.app-icon {
float: left;
margin: 0 8px 4px 8px;
padding: 0;
}
.image-gallery,
.video {
margin: 0 auto 8px auto;
}
/* == Content ad layout == */
.image {
margin: 0 auto 4px auto;
}
/* == Body == */
.body {
/* add more customizations here */
}
/* == App icon == */
.app-icon img {
height: 50px;
width: 50px;
border-radius: 20%;
}
#media (min-width: 360px) and (min-height: 300px) {
.app-icon img {
height: 70px;
width: 70px;
}
}
/* == Title == */
.title {
display: block;
text-align: left;
}
/* == Button == */
.button {
border: none;
border-radius: 20px;
box-shadow: 0 0 2px rgba(0,0,0,0.12), 0 2px 2px rgba(0,0,0,0.24);
}
.button-link {
display: block;
position: relative;
padding: 0 1em;
}
.button svg {
display: none;
}
.button {
width: 90%;
width: calc(100% - 16px);
height: 2.8em;
}
.button-text {
display: block;
line-height: 2.8em;
text-align: center;
}
#media (min-width: 700px) and (min-height: 300px) {
.button {
height: 2em;
}
.button-text {
line-height: 2em;
}
}
/**
* == Large image and video ==
* App install:
* Use .image-gallery selector
* Content:
* Use .image selector
* Video:
* Use .video selector
*/
.image-link,
.image img {
width: 100%;
height: 100%;
}
.image-gallery a,
.image a {
display: block;
line-height: 0;
}
.image-gallery,
.video,
.image {
width: 90%;
width: calc(100% - 16px);
}
.image-gallery,
.video {
height: 50%;
height: calc(100% - 11em);
}
.image {
height: 50%;
height: calc(100% - 10em);
}
#media (min-width: 700px) and (min-height: 300px) {
.image-gallery,
.video {
height: calc(100% - 8.5em);
}
.image {
height: calc(100% - 8em);
}
}
/* == Attribution == */
.attribution {
background-color: #ffffff;
border-radius: 2px;
color: #aeaeae;
display: table;
font-size: 10px;
line-height: 13px;
margin: 4px 8px;
padding: 0 3px;
position: absolute;
top: 0;
left: 0;
}
.rtl .attribution {
background-color: #ffffff;
left: auto;
right: 0;
}
/* == Other == */
.ads a {
text-decoration: none;
}
.ads, .ad {
/**
* DO NOT TOUCH OR REMOVE
* Will break image rendering
*/
height: 100%;
width: 100%;
padding: 0;
word-wrap: break-word;
}
.ad {
/* Padding for attribution */
padding-top: 23px;
height: calc(100% - 23px);
}
#DanielStorm found how to change it but now Admob does not allow it
I'm not really familiar with CSS but you can inspect the element and see that the id is abgbg and that its color is set to #cdcccc by default. I've changed it to orange(#FFA500) in the screenshot. I'm not sure how to express this in CSS, or if it is even possible, but this should point you in the right direction.
Edit:
After playing around with it for a miniute you can change the background color like so:
.abgbg {
fill: #FFFFFF !important;
}

Hide an element through CSS code

I do not know css and it seems hard to display a menu through my self-hosted wordpress site theme in the mobile version. The idea is to use the following code:
#sidebar-primary { display: none; }
Though seems that nothing happens when I add it. Is there a way to hide this element? Below is th whole code when the mobile version is present. Thanks
#media only screen and (max-width: 767px) {
.wrap { max-width: 300px; }
#branding {
float: left;
width: 100%;
position: relative;
}
#sidebar-header {
width: 100%;
margin-bottom: 10px;
}
.featured-wrapper, .aside, .content-wrap, #content, #sidebar-subsidiary .widget, #respond { width: 100%; }
.featured-post h2.entry-title a {
font-size: 12px;
line-height: 1.4em;
padding-right: 15px;
bottom: 87px;
}
.featured-post .byline {
bottom: 63px;
padding: .25em 15px .25em 1.3em;
}
.home.singular .byline { font-size: 10px; }
.menu-toggle {
display: block;
width: 100%;
}
#menu-primary {
float: left;
clear: both;
width: 100%;
margin-top: 10px;
}
#menu-primary .menu, .menu ul {
float: left;
width: 100%;
}
#menu-primary ul li {
clear: left;
display: block;
padding-left: 0;
background: none;
}
#menu-primary ul li a {
font-size: 20px;
margin-left: 0;
padding: 12px 15px;
}
#menu-primary li li a { font-size: 18px; }
#menu-primary li ul, #menu-primary li li { border: none !important; }
#menu-primary li li a:hover { background: none; }
#menu-primary ul li ul {
display: block !important;
float: left !important;
visibility: visible !important;
}
#menu-primary li ul {
display: block !important;
position: relative !important;
top: 0;
left: 30px;
}
#menu-primary ul li li ul { left: 30px !important; }
#menu-primary li:hover ul, #menu-primary li.sfHover ul {
display: block !important;
top: 0 !important;
}
#menu-primary li:first-child ul { left: 0; }
#menu-primary .sf-sub-indicator { background: none !important; }
#menu-secondary .sf-sub-indicator { background: none !important; }
.hentry {
width: 100%;
margin-right: 0;
}
.page-template-front .hentry:hover .read-more, .archive .hentry:hover .read-more, .search .hentry:hover .read-more { display: none; }
.page-template-front .hfeed-more .hentry {
float: left;
width: 100%;
margin-right: 0;
}
.comment-list li li { padding-left: 0; }
#sidebar-primary, #sidebar-secondary, #sidebar-subsidiary {
width: 100%;
clear: left;
}
#footer-content, #menu-subsidiary {
width: 100%;
margin-bottom: 20px;
}
#menu-subsidiary .menu { float: left; }
#menu-subsidiary li {
background: none;
float: none;
padding-left: 0;
margin-bottom: .4em;
}
#menu-subsidiary li a {
font-size: 10px;
line-height: 2.5em;
}
textarea { width: 96%; }
}
If it is not working then it looks like the style for mobile devices are defined in different #media query
Mostly max-width : 320px #media query is used for mobile devices
For mobile devices max-width : 320px just check if it is there and add styles in that query
#media only screen
and (max-width : 320px) {
/* Styles */
}
and more information on #media queries can be found here and here
Did you try adding !important to your style?
#sidebar-primary { display: none; !important}
Are you sure that you have not missed any other
#media only screen and (max-width: xyz px)
May be
#media only screen and (max-width: 767px)
style are not calling.
Check with other #media tag if exists in css.
The right way to force the element to not be displayed is to use the css below:
#sidebar-primary { display: none !important;}
semi-colon after !important
Even if you set the display to none it will still appear when you inspect the dom element. To remove it entirely you need to use jquery or javascript the triggers on document ready that removes the element.
$(document).ready(function(){
if($(window).width() < 767){
$('#sidebar-primary').remove();
}
})
Hope this helps

I Need To Make Page Content Min-Height 100 % But Isn't Work

i need to make my responsive css page content 100 % min-height ... i need help..
#media (min-width: 980px) and (max-width: 1280px) {
.page-boxed .header .dropdown .username {
display: none;
}
}
#media (min-width: 980px) {
/***
Page sidebar
***/
.page-sidebar {
position: absolute;
width: 225px;
min-height:100%;
}
.page-sidebar-fixed .page-sidebar {
position: fixed !important;
top: 41px;
}
.page-sidebar-fixed ul.page-sidebar-menu > li.last {
margin-bottom: 15px !important;
}
.page-sidebar-fixed.page-sidebar-hover-on .page-sidebar {
z-index: 10000;
width: 35px;
}
.page-sidebar-fixed.page-sidebar-hover-on .page-sidebar .selected {
display: none;
}
.page-sidebar-fixed.page-sidebar-hover-on .page-content {
margin-left: 35px;
}
.page-sidebar-fixed.page-sidebar-hover-on .footer {
margin-left: 35px;
}
.page-sidebar-fixed .page-sidebar-closed .page-sidebar .sidebar-search .submit,
.page-sidebar-fixed .page-sidebar .sidebar-toggler {
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.page-sidebar-hovering {
overflow: hidden !important;
}
.page-sidebar-hovering .sub-menu,
.page-sidebar-hovering span.title,
.page-sidebar-hovering span.arrow {
display: none !important;
}
.page-sidebar-hovering .submit {
opacity: 0;
width: 0 !important;
height: 0 !important;
}
/***
Page content
***/
.page-content {
margin-left: 225px;
margin-top: 0px;
min-height: 760px;
}
.page-sidebar-fixed .page-content {
min-height: 600px;
}
.page-content.no-min-height {
min-height: auto;
}
/***
Footer
***/
/* fixed sidebar */
.page-sidebar-fixed .footer {
margin-left: 225px;
background-color: #fff;
}
.page-sidebar-fixed .footer .footer-inner {
color: #333;
}
.page-sidebar-fixed.page-sidebar-closed .footer {
margin-left: 35px;
}
.page-sidebar-fixed .footer .footer-tools .go-top {
background-color: #666;
}
.page-sidebar-fixed .footer .footer-tools .go-top i {
color: #ddd;
}
/* boxed layout */
.page-boxed .header .brand {
margin-left: 0px !important;
width: 226px;
}
.page-boxed .header .brand img {
margin-left: 10px;
}
}
/***
For tablets and phones
***/
#media (max-width:979px) {
/***
Body
***/
body {
margin: 0px !important;
}
/***
Page header
***/
.header {
margin: 0 !important;
}
.header .nav li.dropdown i {
display: inline-block;
position: relative;
top:1px;
right:0px;
}
.header .nav {
margin-bottom: 0px !important;
}
.header .brand {
margin-left: 0px !important;
padding-left: 0px !important;
}
.header .brand img {
margin-left: 2px !important;
}
/***
Page container
***/
.page-container {
margin: 0 !important;
padding: 0 !important;
}
.page-header-fixed .page-container {
margin-top: 0px !important;
}
/***
Page content
***/
.page-content {
margin: 0px !important;
padding: 0px !important;
min-height: 280px;
}
/***
Page sidebar
***/
.page-sidebar {
margin: 0 10px;
}
.page-sidebar.in {
margin: 15px;
position: relative;
z-index: 5;
}
.page-sidebar .sidebar-toggler {
display: none;
}
.page-sidebar ul {
margin-top:0px;
width:100%;
}
.page-sidebar .selected {
display: none !important;
}
.page-sidebar .sidebar-search {
width: 220px;
margin-top: 20px;
margin-bottom:20px;
}
/***
Page title
***/
.page-title {
margin: 15px 0px;
}
/***
Styler panel
***/
.styler-panel {
top:55px;
right:20px;
}
}
#media (min-width: 768px) and (max-width: 1280px) {
/***
Form wizard
***/
.form-wizard .step .desc {
margin-top: 10px;
display: block;
}
/***
Pricing tables
***/
.pricing-table .rate .price,
.pricing-table2 .rate .price {
width: 100%;
display: block;
text-align: center;
margin-bottom: 10px;
}
}
#media (min-width: 768px) and (max-width: 979px) {
/***
Body
***/
body {
padding-top: 0px;
}
/***
Page sidebar
***/
.page-sidebar .btn-navbar.collapsed .arrow {
display: none;
}
.page-sidebar .btn-navbar .arrow {
position: absolute;
right: 25px;
width: 0;
height: 0;
top:50px;
border-bottom: 15px solid #5f646b;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
}
}
#media (max-width: 767px) {
/***
Page header
***/
.header .navbar-inner .container-fluid,
.header .navbar-inner .container {
margin-left: 10px !important;
margin-right: 10px !important;
}
.header .top-nav .nav{
margin-top: 0px;
margin-right: 5px;
}
.header .nav > li > .dropdown-menu.notification:after,
.header .nav > li > .dropdown-menu.notification:before {
margin-right: 180px;
}
.header .nav > li > .dropdown-menu.notification {
margin-right: -180px;
}
.header .nav > li > .dropdown-menu.inbox:after,
.header .nav > li > .dropdown-menu.inbox:before {
margin-right: 140px;
}
.header .nav > li > .dropdown-menu.inbox {
margin-right: -140px;
}
.header .nav > li > .dropdown-menu.tasks:after,
.header .nav > li > .dropdown-menu.tasks:before {
margin-right: 90px;
}
.header .nav > li > .dropdown-menu.tasks {
margin-right: -90px;
}
/* Header logo */
.header .brand {
margin-left: 0px !important;
width: 110px;
}
/***
Page content
***/
.page-content {
padding: 10px !important;
}
/***
Page title
***/
.page-title {
margin-bottom: 20px;
}
/***
Styler pagel
***/
.styler-panel {
top:58px;
right:12px;
}
/***
Page breadcrumb
***/
.breadcrumb {
padding-left: 10px;
padding-right: 10px;
}
/***
Portlet form action
***/
.portlet-body.form .form-actions{
padding-left: 15px;
}
/***
Gritter notification
***/
#gritter-notice-wrapper {
right:1px !important;
}
/***
Form input validation states
***/
.input-icon .input-error,
.input-icon .input-warning,
.input-icon .input-success {
top:-27px;
float: right;
right:10px !important;
}
/***
Advance tables
***/
.table-advance tr td.highlight:first-child a {
margin-left: 8px;
}
/***
Footer
***/
.footer {
padding-left: 10px;
padding-right: 10px;
}
.footer .go-top {
float: right;
display: block;
margin-right: 0px;
}
/***
Vertical inline menu
***/
.ver-inline-menu li.active:after {
display: none;
}
/***
Form controls
***/
.form-horizontal .form-actions {
padding-left: 180px;
}
.portlet .form-horizontal .form-actions {
padding-left: 190px;
}
}
#media (max-width: 480px) {
/***
Header navbar
***/
.header .nav {
clear:both !important;
}
.header .nav > li.dropdown .dropdown-toggle {
margin-top:3px !important;
}
.header .nav li.dropdown .dropdown-toggle .badge {
top: 11px;
}
/***
Page sidebar
***/
.page-sidebar.in {
margin-top: 7px !important;
}
/***
Styler panel
***/
.styler-panel {
top:92px;
right:12px;
}
/***
Page title
***/
.page-title small {
display: block;
clear: both;
}
/***
Dashboard date range panel
***/
.page-content .breadcrumb .dashboard-date-range {
padding-bottom: 8px;
}
.page-content .breadcrumb .dashboard-date-range span {
display: none;
}
/***
Login page
***/
.login .logo {
margin-top:10px;
}
.login .content {
padding: 30px;
width: 222px;
}
.login .content h3 {
font-size: 22px;
}
.login .content .m-wrap {
width: 180px;
}
.login .checkbox {
font-size: 13px;
}
/***
Form controls
***/
.form-horizontal.form-bordered .control-label {
float: none;
width: auto;
padding-top: 0;
text-align: left;
margin-top: 0;
margin-left: 10px;
}
.form-horizontal.form-bordered .controls {
padding-top: 0 !important;
border-left: 0 !important;
}
.form-horizontal.form-bordered.form-label-stripped .control-group:nth-child(even) {
background-color: none !important;
}
.form-horizontal.form-bordered.form-label-stripped .control-group:nth-child(even) .controls {
background-color: none !important;
}
.form-horizontal.form-row-seperated .control-label {
float: none;
width: auto;
padding-top: 0;
text-align: left;
margin-left: 10px;
}
.form-horizontal.form-row-seperated .controls {
border-left: 0;
margin-left: 10px;
}
.portlet .form-horizontal .form-actions {
padding-left: 10px;
}
/***
Hidden phone
***/
.hidden-480 {
display: none;
}
/***
Modal header close button fix
***/
.modal-header .close {
margin-top: 5px !important;
}
/***
Fix text view
***/
.control-group .controls .text {
display: block !important;
margin-bottom: 10px;
}
}
#media (max-width: 320px) {
.header .nav > li.dropdown .dropdown-toggle {
padding-left: 8px !important;
padding-right: 8px !important;
}
/***
Hidden phone
***/
.hidden-320 {
display: none;
}
.header .brand {
width: 100px;
}
}
You may want to look at the MDN article on min-height
The min-height CSS property is used to set the minimum height of a
given element. It prevents the used value of the height property from
becoming smaller than the value specified for min-height.
Specifically- you need to also define the height when declaring min-height, as that is what min-height is calculated relative to.
If the height of the containing block is not specified explicitly
(i.e., it depends on content height), and this element is not
absolutely positioned, the percentage value is treated as 0.
The most common way to have content 100% of viewport height is to assign a height value of 100% to the html and body elements, then the main page 'container'. One other approach is to have an absolutely positioned element with a top and bottom setting of zero.

Resizing container div when inner div position changes

I've got a container div (the background in the picture below) and an inner div that contains images (social icons).
I want my images to overflow out of the bounds of the container div (as you can see in the image), but at the same time I want the container to resize: its height should decrease when my images overlap its top border. So there shouldn't be that lower empty border: the container behaves like if the images were fixed, while they are not.
Here's the image:
How can I do that?
EDIT: This is what I'd like to obtain (well, something like this I mean :P )
The height of the container div (the dark background you see) is dynamically set by its content.
try giving the position of inner div to position:absolute in relative with the parent div
then you can play around with the inner divs by adjusting the top,left,bottom and right properties
// css
body{ background: url("http://1.bp.blogspot.com/-OowkzBiSOJU/Ud0G3T325lI/AAAAAAAACfY/syhVEMuuSOw/s1600/tiny_grid.png") repeat scroll 0 0 transparent; color: #666; height: 100%; padding: 0; font-family: 'Lora',Georgia,Serif; font-size: 18px; line-height: 29px; border-top: 5px solid #4690B3; }
.clr { clear:both; float:none; }
.ct-wrapper { padding:0px 20px; position:relative; max-width:1230px; margin: 0 auto; }
.header-wrapper {
background: #fff; border-bottom: 1px solid #ccc; display: inline-block; float: left; width: 100%; }
/***** Optin Form CSS *****/
.opt-in .inner { background: url("http://3.bp.blogspot.com/-YfUnP1wOFzQ/Ud0G21XXRWI/AAAAAAAACfQ/Hg5Gakd69tQ/s1600/home-bg.png") repeat scroll 0 0 transparent; padding: 10px 0 0; font-style: italic; color: #ccc; text-shadow: 0 1px 1px #000000; margin-top:50px;height:50px; }
.opt-in .opt-in-wrap { margin-right: 40%; }
.opt-in .info { float: left; width: 80%; }
/*****************************************
Responsive styles
******************************************/
#media screen and (max-width: 1024px) {
#header, .header-right { float: none; text-align: center; width: 100%; }
.header-right .widget-content { margin: 0; }
}
#media screen and (max-width: 960px) {
.ct-wrapper{ padding:0 15px; }
.main-wrapper, .opt-in .opt-in-wrap{ margin-right:0; width:100%; }
.sidebar-wrapper{ float: left; width: auto; margin-left: 20px; }
.nav-menu ul { text-align: center; }
.nav-menu ul li { float: none; }
.opt-in .inner .ct-wrapper { padding: 0 48px; }
.opt-in .info { text-align: center; }
.opt-in .signup-form { margin-top: 30px; width: 95%; float: left; }
#subbox { width: 60%; }
}
#media screen and (max-width: 768px){
#header p.description { margin: 0; }
.header-right { display: none; }
#comment-editor { margin:10px; }
.footer { width: 50%; }
}
#media screen and (max-width: 500px){
#header img { width:100%; }
.opt-in .inner .ct-wrapper { padding: 0 10px; }
}
#media screen and (max-width: 420px){
.comments .comments-content .datetime{ display:block; float:none; }
.comments .comments-content .comment-header { height:70px; }
}
#media screen and (max-width: 320px){
.footer { width: 100%; }
.ct-wrapper{ padding:0; }
.post-body img{ max-width: 220px; }
.comments .comments-content .comment-replies { margin-left: 0; }
}
/*****************************************
Hiding Header Date and Feed Links
******************************************/
h2.date-header{display:none;}
.opt-in .social-div {
background: rgba(0, 0, 0, 0.0);
border: none;
float: right;
font-size: 16px;
text-align: center;
position: absolute;
top: -55px;
}
.opt-in .social-div .form-inner { font-size: 16px; margin: 35px; }

Media Queries being read with wrong syntax

Once I accidentally left out some proper syntax for my media queries at the stated mobile viewport. It displayed correctly, which is awesome, but I'd like to be using the correct syntax, and am curious to know why / how this is occurring. Below are the styles involved.
/* Smartphones (Landscape) ----------- */
#media only screen and (min-width: 320px) and (max-width: 480px)
ul.ui-tabs-nav li.ui-state-active a {
background-color: #C6C699;
height: 17px;
text-shadow: none;
width: 77px;
}
.content .full header, .content .full .entry-summary, .content .full .entry-content, .content .full .entry-meta, .content .full .edit-link {
margin-top: 3px;
padding: 15px;
width: 100%;
}
#topbgimg { display: none; }
#topvidarea {
margin-left: 21%;
margin-right: 20%;
margin-top: -5px;
max-width: 400px;
}
#topmenucontain { display: none; }
.fmenu { display: none; }
#clogo { display: none; }
#youtube1, #youtube2 { display: none; }
#wrapper {
margin: 0 1em;
}
h1 {
font-size: 2em;
}
#logoimg { display: none; }
#notification {
height: 200px;
margin: 0;
width: 100%;
padding-top:20px;
}
.ui-tabs .ui-tabs-nav li a {
border: 3px solid white;
color: white;
}
#branding {
width: 100%;
padding: 1em 0;
margin: 0;
text-align: center;
}
#topbtn, #topbtn2, #topbtn3 {
width: 75px;
}
#topbtnbuy {
background: none repeat scroll 0 0 #C6C699;
border: 1px solid #C6C699;
color: #333333;
display: inline;
float: left;
font-family: Georgia;
font-size: 12px;
height: 42px;
margin-right: 10px;
margin-top: -1px;
width: 25%;
}
a.box:link {
min-width: 70%;
}
nav#access {
border-bottom: 1px dashed #CFCFCF;
position: relative;
text-align: center;
}
nav#access ul.menu li:nth-child(n+5) {
display: none;
}
.content {
min-height: 0;
background-image: none !important;
border-bottom: 1px dashed #CFCFCF;
}
/* Hide Background & Overlay Images */
.overlay {
display: none;
}
.has-background {
min-height: 0;
}
.content header, .content .entry-summary,
.content .entry-content, .content .edit-link,
footer.entry-meta {
width: 100%;
}
.content header, .has-background header {
margin-top: 2em;
}
.content header h2 a, .single .content header h2 {
font-size: 2em;
}
.content section.right,
.content section.left,
.content section.full,
.content section.center {
padding: 0;
}
.content section.center header,
.content section.center .entry-summary,
.content section.center .entry-content,
.content section.center .edit-link,
.content section.center footer.entry-meta,
.content section.right header,
.content section.right .entry-summary,
.content section.right .entry-content,
.content section.right .edit-link,
.content section.right footer.entry-meta {
left: 0;
}
#comments {
margin: 1em 0;
}
#comment, #commentform input,
#commentform #submit, #commentform #comment {
width: 416px;
}
.commentlist {
width: 424px;
}
#commentform #submit {
width: 430px;
}
#comments, #commentform #comment-reply {
width: 100%;
}
.cat-links, .entry-meta .sep:nth-child(n+4),
.comments-link, .edit-link {
display: none;
}
/* Footer */
#footer {
width: 100%;
padding: 1em 0;
}
#footer-widgets {
margin-bottom: 1em;
}
#footer .widget {
width: 45%;
margin: 0.5em 0;
}
.third-box {
width: 89%;
}
#buybutton { width: 95%; }
.scrolldowntext { margin-top: 40px; }
#notification {
background-color: #333333;
border-bottom: 5px solid #C6C699;
font-size: 22px;
height: 200px;
padding-top: 20px;
position: absolute;
width: 100%;
z-index: 9990;
}
#topcaption {
display: none;
}
#logoimg { display: none;}
#topmenucontain {
margin: -33px auto 0;
width: 50%; }
a.box:link {
color: #C6C699;
display: inline;
float: left;
font-family: Georgia;
font-size: 12px;
height: 50px;
margin-right: 10px;
min-width: 75px;
}
#videoscreenshot { height: 215px; width: 100%; }
.fancybox-iframe { display: hidden; }
}
Once I left out the additional { at the end of '#media only screen and (min-width: 320px) and (max-width: 480px)' all my media queries were being read?
Update: Just tried removing all styles within specified above viewport, in attempts to start from scratch properly in case some styles were whatever.
BUT, within starting, I simply am trying to hide the top menu within the viewport. And this is ignored and not rendering for some reason?
/* Smartphones (Landscape) ----------- */
#media only screen and (min-width: 320px) and (max-width: 480px) {
#topvidarea {
margin-left: 24%;
margin-right: 20%;
margin-top: -265px;
max-width: 400px;
}
#topmenucontain { display: none; }
}
You have no opening bracket in your media query but you do have a closing one:
#media only screen and (min-width: 320px) and (max-width: 480px) {
......
}
All your other media queries where probably being read because you were not properly closing your first query, and thus the query did not know where to begin and end.

Resources