Width:100% without Position:absolute/fixed - css

By using the property position:absolute; I have to mention the correct size of all layers (in my case 3 layers "#header", "#mybody", "#footer") where in my website #mybody's height is dynamic. So, I need #footer's position should be something like relative but using relative I am unable to set with:100%; Even if I set width:100% I am not getting complete 100% using relative. However I am getting 100% using absolute but I can't use absolute for above reason(s). Also I don't want footer to be fixed. How can I set my footer's width to 100% without using absolute or fixed position? Using width:100% with other than absolute or fixed doesn't resulting complete 100% to me.
Code:
mheadf {
position:relative;
width:100%;
height:35px;
border:thin solid black;
}
mbody {
position:relative;
width:800px;
height:500px;
border:thin solid black;
}
mfootf {
position: relative;
width:100%;
height:115px;
border:thin solid black;
}
-->

Using width:100%; should make the div 100% in width, assuming there are no margins or paddings on your body/div. Remove those and you'll be good to go.

Related

CSS3 background image placement

I am in the process of creating a simple placeholder page to announce a new website. The page consists of nothing other than
a centered background logo image
a "catch phrase" immediately below that image
I thought this would be easy - I place a positioned background image with its size specified and then place an absolutely positioned h1 header to get the "catch phrase" right below the background image.
*
{
color:white;
font-family:arial;
margin:0 !important;
padding:0 !important;
}
body
{
background-color:black;
background-origin:border-box;
background-image:url('https://unsplash.it/1064/800');
background-size:auto 25%;
background-position:center 37.5%;
background-repeat:no-repeat;
height:100vh;
}
h1
{
text-align:center;
position:absolute;
top:62.5%;
right:0;
left:0;
}
<h1>CSS3 is Cool!</h1>
This is working to the understanding that
background-origin:border-box;
background-position:center 37.5% with
background-size:auto 25% would
yield an image with
The background image centered horizontally with its top left hand corner at 37% of its container height (set to 100vh)
The absolutely positioned h1element is at (37.5 + 25)% from the top
For good measure I set padding:0and margin:0on everything. However, the end result is not quite as expected - there is still way too much space between the bottom of the logo image and the top of the h1header. Clearly, I am misunderstanding some aspect of background positioning and/or size here. I'd be much obliged to anyone who might be able to put me on the right track
When using percent for background images, it doesn't work at all as one first think.
When you set background position using percent, that positions the image such that X% of the way across itself aligns with X% of the way across the element. This article at CSS Tricks shows it quite well: percentage-background-position-works
Use viewport height units vh instead
*
{
color:white;
font-family:arial;
margin:0 !important;
padding:0 !important;
}
body
{
background-color:black;
background-origin:border-box;
background-image:url('https://unsplash.it/1064/800');
background-size:auto 25%;
background-position:center 37.5vh;
background-repeat:no-repeat;
height:100vh;
}
h1
{
text-align:center;
position:absolute;
top:62.5vh;
right:0;
left:0;
}
<h1>CSS3 is Cool!</h1>

Keeping columns on the bottom

I am trying to bring the .day_line columns on the bottom of .lines_container. I tried to set extra .lines in the .day_line colmn and give them
position:absolute;
bottom:0
and to parent
position:relative;
but it doesn't push the lines on the bottom...
Any reason/solution?
My codes here http://jsfiddle.net/BqDfn/
Thnx!
If the container is going to keep that fixed height, you could do this:
.day_line {
height: 100%;
}
I didn't understand your question very well, but i guess you want those strips to go all the way down, if so set the Height: 100%
.day_line{
float:left;
margin-left:50px;
position:relative;
width:10px;
height:100%; // Changed to 100%
background:red;
overflow: hidden;
}

CSS "right" property is not consistent between objects

So, for a website, I have the site divided up with divs and iframes: an iframe for a sidebar, an iframe for a footer, and a big div in the middle for the body content. In order to get everything static and well-fitting, I used the code here:
.bodycontent{
position:fixed;
top:0px;
left:150px;
right:0px;
bottom:100px;
overflow:auto;
}
.footerframe {
position:fixed;
left:150px;
bottom:0px;
right:0px;
height:100px;
border-top: 2px solid #888;
border-right: 2px solid #888;
border-top-right-radius:4px;
}
This was intended to get both the main div and the footer iframe to stretch across the page. It works for the main div, but not the footer. What is up with that inconsistency?
There are two problems with your code:
Top/Bottom or Left/Right should be used in pairs always, not in four values. If you use top, don't use bottom; if you use left don't use right.
If you want an element with position fixed to stretch to the whole page, you should give it width:100%
:)

change fluid image aspect ration css

I'm trying to place 6 images one next to another with css,
the whole thing should be able to scale pretty well in most displays (except for mobile for the moment)
so I've made this:
http://pelloponisos.telesto.gr/galleryTest/test/gallery.php#
(apparently I'm trying to make yet another carousel)
most of my images have a bigger width than height so when I scaled them I just put
width:x% in the li container and 100% for the image width.
but the sixth image is different and it causes quite a bit of trouble
I tried setting the height too but you can only scale the images based on one of the two.
The only thing that worked so far was to put a static height in the ul and then scale in both width and height but then it's not a fluid grid.
is there any way to make all li elements have a fluid height and then scale all images based on that? or if not
is there any way to make any image with different ratio scale to the one I specify in the css?
I stripped down your code a little bit, but this seems to get closer to the idea. The trick is to set the width in the container (.upper ul li) then for the images use: max-width:100%; height:auto. Also, the padding is now in %.
#carousel{
position:relative;
}
#wrapper{
margin:0 auto;
}
#slides{
width: 100%;
}
.upper ul li{
width: 200px;
max-width: 100%;
list-style:none outside none;
float:left;
padding-bottom:5px;
padding:2%;
}
img.galleryThumbnail{
max-width:100%;
height:auto;
}
.info{
display:none;
}
#buttons img{
position:absolute;
top:90px;
}
#buttons #prev img{
position:absolute;
left:29px;}
#buttons #next img{
position:absolute;
right:21px;
}

Centering content issue

Can anyone tell me what I need to do in order to get the following page to center the contents correctly?
I've been trying to work with something else I used earlier in the day from here:
#divWrapper {margin:0 auto; text-align:center;}
#div {text-align:left;}
But this isn't working for me. One of the pages I need help with is here:
REDACTED
Thank you for any help, I'm just trying to get this fixed before I can head off to bed :\
#main-inner {
position: relative;
width: 960px;
border-top: 3px solid #DADADA;
margin: 20px auto 0;
overflow:auto;
zoom:1;
}
try this one. replace the existing with this. it should center the content.
It needs a width! to work correctly.
Give your #divWrapper a width. By default the width will expand as far as the containing element, so to create the appearance of it being centered, its width needs to be less than its containing element.
You can only center elements with margin:0 auto when you provide a fixed width from which the margins can position themselves from automatically. So add a fixed with to your wrapper and it should work.
You might also need to specify text-align:center; if you want the actual div contents centered.
Try this #divWrapper {margin:0 auto; text-align:center;width:960px}
#div {text-align:left;width:500px}
Edit:
There are typing mistakes in your CSS.
Check this updated CSS for margin-inner & margin-inner-right. It will fix your problem
#main-inner {
float:left;
position:relative;
width:100%;
border-top:3px solid #dadada;
margin-top:20px;
margin-right:auto;
margin-left:auto;
}
#main-inner-right {
position:relative;
width:640px;
text-align:left;
margin-top:20px;
margin-right:auto;
margin-left:auto;
}

Resources