I have an image that fixes itself to 100% of the page width. It stays the same size (on the screen) no matter what resizing the user does in their browser.
I now need to add a single Enter Your Name form field on top of the image. However, I want the text and form field sizing and position to stay the same no matter what the user does to resize their browser window. This is important because I need to overlay the form field table just perfectly on top of the image or else it will look bad.
Here's my current CSS:
.fixedimage img{
width:100% !important;
height:auto;
display:block;
}
Here's my current HTML:
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD WIDTH="100%">
<div class="fixedimage">
<center><img src="FixedImage.jpg"></center>
</div>
</TD>
</TR>
</TABLE>
How would I overlay the table in a particular spot on top of the FixedImage.jpg? And how would I keep it being the same size when a user resizes or zooms in/out in their browser window?
Thanks for your help with this!!!
See this fiddle:
http://jsfiddle.net/nV7tP/1/
CSS:
.fixedimage{
width:100% !important;
height:auto;
display:block;
background:url(http://www.hdwallpaperspick.com/wp-content/uploads/2013/06/beautiful-autumn-scenery-723-2.jpg);
background-position:50% 50%;
background-size:cover;
}
.fixedimage form{
width:100%;
color:white;
font-size:40px;
text-align:center;
}
.fixedimage form input{
width:250px;
height:30px;
}
Response to the comment below:
Try this fiddle to show the entire background image:
http://jsfiddle.net/nV7tP/2/
.fixedimage{
position:absolute;
width:100% !important;
height:auto;
display:block;
font-size:40px;
}
.fixedimage img{
position:absolute;
}
.fixedimage form{
position:absolute;
width:100%;
color:white;
text-align:center;
}
.fixedimage form input{
width:250px;
height:30px;
}
Note : It would be better if you use the CSS of first posted fiddle.Its the type of CSS mostly used in present popular sites.
Set the image width to 100% .This will give the output you asked:
See this fiddle: http://jsfiddle.net/nV7tP/5/
or if you want a container with minimum width see this http://jsfiddle.net/nV7tP/6/ .
Related
I'm trying to create a banner featuring some services I provide, the image below is exactly how I want it (desktop view) but when I resize the browser the text gets pushed underneath the image and is hidden by over elements of the page overlapping.
How do I make it so the image and text resize with the browser and looks exactly the same as it does on desktop?
I created an example on here http://jsfiddle.net/b7a8cvLb/4/
And my CSS
.info_banner {
background-color:white;
max-width:1166px;
margin:0 auto;
padding: 5px 5px 0px 5px;
text-align:center;
font-size:1em;
height:65px;
}
.info_block {
display:inline-block;
width:20%;
border-right-style:solid;
border-right-width:2px;
border-right-color:#F8F8F8;
height:65px;
vertical-align: text-top;
}
.info_block img {
max-width:100% !important;
height:auto;
display:inline-block;
float:left;
}
.info_block h5 {
height:100%;
width:100%;
margin:0;
}
If needs be I can set the images to display:none at a certain browser width but I'd prefer to avoid doing this.
I can see your images are already scaling down, if you want to scale down your text too you'll need to step it down using media queries.
Hope that helps!
I am trying to zoom a image which is inside a div.
When page is loaded i am showing 300*300 size image inside a 400*400 size div.
So, to show the image at the center of the div i am using the following css.
#img1{
width:300px;
height:300px;
position:absolute;
margin:auto;
top:0;
bottom:0;
left:0;
right:0;
}
with the above css code i can able to show the image at the center of the div.
but when a user clicks on zoom button i am increasing the height and width of the image. If it becomes 600*600 size image, i have to show scroll bar so the user can scroll the div to show the full image.
For this i set overflow:auto to div.
But the problem is i can't see the full image when i scroll the div. This may be due to the position:absolute property of image. How can i fix this.
I created a fiddler also. There i am showing 2 divs before and after zooming image. Please check.
http://jsfiddle.net/codingsolver/L4qdL/1/
Can you try this;
HTML
<div class="outer">
<div class="inner">
<img id="img1" src="http://siliconangle.com/files/2012/04/HTML5_Wallpaper_1680x1050.png" />
</div>
</div>
<button class="zoomout" data-zoom="out">Zoom Out</button >
<button class="zoomin" data-zoom="in">Zoom In</button >
CSS
.outer{
height:400px;
width:400px;
overflow:auto;
border:1px solid black;
float:left;
margin:30px;
text-align:center;
}
.inner {
height:400px;
width:400px;
display:table-cell;
vertical-align:middle;
}
img {
width:300px;
height:300px;
}
http://jsfiddle.net/L4qdL/7/
I have some trouble with my website.
I have a contact from which is based on 4 divs posisioned like this:
div 1 is the place where you can fill out your information
div 2 is the textarea for your message and a send button
div 3 is contact information
and div 4 are social media icons.
this all works great. on mobile they're are scaled beneath eachother and it works like a charm.
But now my designer want to add a format for landscape posioned mobiles (which I agree with him is nesacery because the contact page is way to long if you keep all the divs beneath eachother. so what he came up with is:
so div 1 and 2 beneath eachother with all the fill out fields. and on the right the information en social media icons.
but here starts my problem. because floating items will go beneath eachother in order. this means that div2 will stay beside div 2 and div 3 will be beneath div 1 like this (the arrow incades which 2 I want to swap:
is there any way to change this by just using css? the solution I came up with is writing a a new code posisioned in the good way for this problem and make it display none until the right landscape mode is registerd.. but this would be a bit of a heavy solution for such a problem in my opinion. so anyway has a better idea:
here a fiddle:http://jsfiddle.net/skunheal/p6Yy6/
#container{
height:200px;
width:400px;
background:#212121;
}
#id1{
height:90px;
width:190px;
background:#fff;
float: left;
}
#id2{
height:90px;
width:190px;
background:#fff;
float: left;
}
#id3{
height:90px;
width:190px;
background:#fff;
float: left;
}
#id4{
height:90px;
width:190px;
background:#fff;
float: left;
}
this is my css right now. in the jsfiddle is the position of every box displayed. aldo it doesnt matter if the boxes on the right are swapped.
Hope anyone can help me out!
If I understand corectly the "responsive" behavior you are looking for , you ca wrap the two first divs together and the two last ones together. and float the wraps to the left. Then using a percent width and max-width/min-width you can achieve the desired behaviour.
See this FIDDLE (I modified the width of #container in your fiddle so it is responsive)
HTML :
<div id="container">
<div id="left_wrap">
<div id="id1">left above</div>
<div id="id2">left under</div>
</div>
<div id="right_wrap">
<div id="id3">right above</div>
<div id="id4">right under</div>
</div>
</div>
CSS (modified)
#left_wrap,#right_wrap{
width:50%;
max-width:380px;
min-width:190px;
float:left;
}
#container {
height:100%;
width:100%;
background:#212121;
}
#id1,#id2,#id3,#id4 {
height:90px;
width:190px;
background:#fff;
float: left;
}
Now, if you change the width of the fiddle window, you will see that if the window width is over 760px the divs all align normaly. If the window is between 760px and 380px you get the disired behaviour. If th window is under 190px the divs all stand on to of each other.
Since you are working with fixed height/width on these, you should be able to use absolute positioning instead of floats.
#container{
height:200px;
width:400px;
background:#212121;
position:relative;
}
#id1{
height:90px;
width:190px;
background:#fff;
position:absolute;
top:0;
left:0;
}
#id2{
height:90px;
width:190px;
background:#fff;
position:absolute;
bottom:0;
left:0;
}
#id3{
height:90px;
width:190px;
background:#fff;
position:absolute;
top:0;
right:0;
}
#id4{
height:90px;
width:190px;
background:#fff;
position:absolute;
bottom:0;
right:0;
}
Hi i'm trying make a website that has a header at the top and and div that loops through some images in the background. at the moment i'm trying just to get it to display one image that is responsive to the screen size so no matter what screen your on the background image will scale to fit the height and width. The problem i'm having is that i can't seem to get display anything without a hardcoded width or height.
heres what i have so far
banner.php
<div id="banner">
<div class="bgslider"></div>
</div>
global.css
/* BANNER */
#banner { style="width:100%; height:100%; position:fixed; left:0;top:50;overflow:hidden; background:#F00; }
.bgslider { style="width:100%; height:750px; position:fixed; left:0;top:50;overflow:hidden; background-image:url(../images/banners/trawberry_Mockup.jpg) }
take out style=" from within the brackets
try this
#banner { width:100%; height:100%; position:fixed; left:0;top:50;overflow:hidden; background:#F00; }
.bgslider { width:100%; height:100%; position:fixed; left:0;top:50;overflow:hidden; background-image:url(../images/banners/trawberry_Mockup.jpg);background-size:cover; }
http://jsfiddle.net/EE2Jc/
So I have a 3-column layout on my webpage, but I can't get the things in the middle column to be centered. The columns on the left and right are of fixed width, so I created a container for the middle column and set its borders to equal the size of the left and right columns. Then, I used the margin:auto property on the div tag inside the middle container that has everything that I want in the middle column. If possible, I want this to work on all browser window sizes. This is my CSS:
#top
{
width:100%;
background-color:#FF0000;
height:30px;
overflow: auto;
width: 100%
}
#right
{
float:right;
width:100px;
background-color:#CCC;
height:100%;
}
#middleCont
{
margin-left:150px;
margin-right:100px;
}
#middle
{
margin:auto;
text-align:left;
}
#left
{
float:left;
width:150px;
height:100%;
}
And since I can't post html without the browser rendering it for some reason, I uploaded the relevant code in a text file: http://www.mediafire.com/?a89kr1bb4uwb4cf
Thanks in advance for the help.
Yes, for one, under #middle, you said text-align: left rather than text-align: center. The instant I changed this, it worked fine.
I inserted different types of tags into the document, including p, div, blockquote, a list, a table, and an image. The only problem I noticed is that the table did not center. Looking at a number of articles, I found that you had already implemented the recommended way of centering a table in CSS. I think that maybe, the only solution to this problem is either to make a table using the center tag or create a new block of text in your CSS file.
You can do what you like, but the recommended way is this:
#center {
margin: auto;
}
Then make a new table with #center as its ID.
<table id="center">
...
</table>
If you choose to use the center tag, you implement it like this:
<center>
<table>
...
</table>
</center>
Hope I helped a little. Good luck.
I do it this way. Working even for internet explorer 6.
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%;">
<tr>
<td width="50%" valign="top" style="width:50.0%;">
</td>
<td valign="top" style="width:900px;">
<div style="width:900px; border:1px solid white;"></div>
</td>
<td width="50%" valign="top" style="width:50.0%;">
</td>
</tr>
</table>
I suppose you can change the text-align:left to text-align:center for the selector #middle
If you want to use the method margin:0 auto for the #middle (and not margin:auto as you have it) then you have to set a fixed width, something like width:400px; or width:20%;.
If you want a fixed width center column then
#middle
/*this will keep the column width constant wile letting the space on either side expand*/
{
margin:auto;
text-align:left;
width: 600px; /* what ever width you want */
}
or specify fixed margins
#middle
/*this wil keep the space on either side constant wile letting the column expand*/
{
margin-left: 150px; /*to center column just keep the left and right margins equal*/
margin-right: 150px;
text-align:left;
}
I hope that answers your question.
P.S. It would have helped if you had posted the html too.
I am not sure if I follow exactly what you are trying to do - but what about if you use percentages rather than pixels for the width of all four divs?
#top
{
width:100%;
background-color:#FF0000;
height:30px;
overflow: auto;
width: 100%
}
#right
{
float:right;
width:25%;
background-color:#CCC;
height:100%;
}
#middleCont
{
margin-left:36%;
margin-right:26%;
}
#middle
{
margin:auto;
text-align:left;
}
#left
{
float:left;
width:35%;
height:100%;
background-color:#CCC;
}