Resizing container div when inner div position changes - css

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; }

Related

Making paragraph responsive in CSS

I'm new to CSS and have encountered a problem. I'm trying to display paragraphs on my website on desktop/global view as
#aeromexico
p {
float: left;
position: fixed;
text-align: left;
max-width: 25%;
padding: 0px 0px 0px 0px;
display:inline-block;
}
but when viewed in mobile and tablet I want them to be viewed as
#aeromexico .col-sm
p {
object-position: top;
text-align: left;
max-width:100%;
display:block;
padding-bottom: 60px;
}
However the second part of the code for mobile view is being ignored and is still displaying as desktop view on mobile. I have attached my whole code below
/Desktop / Global View/
body {
max-width: 1366px;
margin-left: auto;
margin-right: auto;
font-family: 'Open Sans', sans-serif;
padding: 1px;
}
#homepage .col {
float: left;
}
.col-lg {
width: 33.3%;
}
.col-lg img {
width: 100%;
height: auto;
display: block;
}
.slicknav_menu {
display:none;
}
#menu {
float: right;
}
#menu li {
display:inline-block;
}
#menu li a {
text-decoration:none;
color: #454545;
padding: 8px;
font-size: 18px;
}
header {
padding: 10px 0px 20px 0px;
}
ul {
padding-top: 40px;
}
.mylogo {
width: 95px;
}
/*aeromexico*/
#aeromexico .row {
padding:5px;
}
#aeromexico .col {
width: 70%;
margin-right: auto;
float: right;
display:inline-block;
padding-bottom: 40px;
}
#aeromexico .col-lg {
width: 65%;
}
#aeromexico
p {
float: left;
position: fixed;
text-align: left;
max-width: 25%;
padding: 0px 0px 0px 0px;
display:inline-block;
}
/*Tablet View*/
#media (max-width: 768px) {
#menu li {
display:block;
text-align: right;
}
header {
padding:10px;
}
.col-md {
width: 50%;
}
.mylogo {
width: 95px;
}
body {
padding:10px;
}
}
/*Mobile View*/
#media (max-width: 400px) {
.slicknav_menu {
display:block;
}
#menu {
display:none;
}
alt {
width: 95px;
}
.mylogo {
width: 95px;
}
.col-sm {
width:100%;
}
body {
padding:10px;
}
#aeromexico .col-sm {
width:100%;
}
#aeromexico .col-sm
p {
object-position: top;
text-align: left;
max-width:100%;
display:block;
padding-bottom: 60px;
}
}
Did you set up the metatag for the viewport on the HTML header?
<meta name="viewport" content="width=device-width, initial-scale=1">

CSS: What is wrong with my responsive layout? Why does the text in responsive mode shrink so much?

What is wrong with my responsive layout? Why does the text in responsive mode shrink so much? How do I get the text to be a little larger in responsive mode?
Page is found here: http://spammysite.com/rtest.php
Here is screenshot of the text being too small, google chrome phone mode: https://snag.gy/agKCPp.jpg
Below is my code.
<style>
#import url(https://fonts.googleapis.com/css?family=Open+Sans);
body {
font-family: 'Open Sans', sans-serif;
color: #666;
}
p {
font-size: 12px;
}
/* STRUCTURE */
#pagewrap {
padding: 5px;
width: 960px;
margin: 20px auto;
}
header {
height: 100px;
padding: 0 15px;
}
#middle {
width: 616px; /* Account for margins + border values */
float: left;
padding: 5px 15px;
margin: 0px 5px 0px 0px;
}
#sidebar {
width: 270px;
padding: 5px 15px;
float: left;
}
footer {
clear: both;
padding: 0 15px;
}
/************************************************************************************
MEDIA QUERIES
*************************************************************************************/
/* for 980px or less */
#media screen and (max-width: 980px) {
p {
font-size: 12px;
}
#pagewrap {
width: 94%;
}
#middle {
width: 92%;
padding: 1% 4%;
margin: 0px 0px 5px 5px;
float: right;
}
#sidebar {
clear: both;
padding: 1% 4%;
width: auto;
float: none;
}
header, footer {
padding: 1% 4%;
}
}
/* for 700px or less */
#media screen and (max-width: 600px) {
p {
font-size: 20px;
}
#middle {
width: auto;
float: none;
margin-left: 0px;
}
#sidebar {
width: auto;
float: none;
}
}
/* for 480px or less */
#media screen and (max-width: 480px) {
p {
font-size: 20px;
}
header {
height: auto;
}
h1 {
font-size: 2em;
}
#sidebar {
display: none;
}
}
#sidebar {
background: #f0efef;
}
header, #content, #middle, #sidebar {
margin-bottom: 5px;
}
#pagewrap, header, #content, #middle, #sidebar, footer {
border: solid 1px #ccc;
}
</style>
<div id="pagewrap">
<header>
Layout
</header>
<section id="middle">
Middle Section
</section>
<aside id="sidebar">
Sidebar
</aside>
<footer>
Footer text
</footer>
</div>
The below tag fixed the issue
<meta name="viewport" content="width=device-width, initial-scale=1.0">

my bootstrap styles won't render my mobile styles

my bootstrap mobile style won't render unless I add a extra closing brace to the end can someone tell me what I did wrong
this is the styles that I created and they should work but they are not working and they pass the validator test.
#media only screen and (max-width: 766px){
.movie{
width:300px;
height: 300px;
margin:0;
padding:0;
}
body > div > div > h3 {
margin-left: 300px;
padding-top: 200px;
}
a:link {
outline: 0;
font-size: 9px;
display: block;
padding-right: 50px;
}
h3{
font-size: 20px;
margin-top:20%;
}
h3.port {
margin-left: 150px;
color: #9932CC;
margin-top: 50px;
}
img {
float: left;
margin-right: 15px;
width:50%;
height:50%;
margin-top:0;
}
p {
margin-left: 10px;
margin-top:5%;
padding: 0;
color: #9932CC;
font-size: 15px;
}
.navbar .nav > li > a {
color: #9932CC;
}
body > div > div > a > img {
display: none;
}
.navbar-brand {
float: left;
padding: 10px 15px;
font-size: 20px;
}
/* twitter
====================================== */
div#iPhone {background: url("../images/iphone.png") no-repeat;
width:275px;height:500px;
display: inline-block;
padding-top: 90px;
padding-left:2em;
margin-left: 0px;
}
iframe#twitter-widget-0.twitter-timeline[style] {width:70px !important;}
div#iPhone iframe[id^="twitter-widget-0"] {min-width:170px !important;
margin-right: 20px;
}
/* iframe
======================================= */
.movie {
text-align: center;
width: 350px;
height: 345px;
margin-left: 0px;
margin-right: 200px;
}
.paragraph {
width: 50px;
margin-left: 10%;
}
.thumbnail {
color: #333;
margin-left: 100%;
width: 100%;
background-color: transparent;
border:0px;
}
.btn-primary {
color: #000;
background-color: #aff6b8;
border-color:black;
margin-top: 5%;
width:100%;
}
}
}
mobile style won't render unless I add a extra closing brace to the end
Yes, the #media syntax involves an extra set of braces:
#media only screen and (max-width: 766px) {
element {}
}
The last closing brace you added is equivalent to the last one in the code above.

Is there a better way to make these blue lines span the width of the text box?

On my blog siteI have these horizontal blue lines and all I want them to do is span the width of the text box, and the way I did it seems to cause other issues. The only way I could get it to work was to add these funky margins. Is there a simpler way of making it the width of the text box?
.date {
padding: 10px;
margin-left: -42px;
margin-right: -40px;
padding-left: 40px;
display: block;
background: #0076a9;
UPDATED:
#media only screen and (max-width:640px) {
#header, #pageWrapper, #footer {
padding: 30px 20px;
margin-bottom: 0px !important;
}
h1.logo {
text-align: center;
padding-bottom: 10px
}
.slide img {
opacity: 1
}
.sqs-active-slide img {
opacity:1
}
img {margin-bottom: 10px;}
.collection-type-gallery #slideshowWrapper .slide img {
background-color: white !important;
margin: 2px 0;
}
.hentry {
background: #F8F9FC;
padding: 40px;
border-style: solid;
border-color: #E2E7F5;
border-width: 2px
}
Add the following CSS to your media query (or create a new one).
#media only screen and (max-width: 640px) {
.hentry {
padding:20px;
}
.date{
margin-left: -22px;
margin-right: -20px;
padding-left: 22px;
}
.collection-type-blog article header .entry-title {
padding-left:0;
padding-right:0;
}
}

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