CSS - Dynamically Resizing Image
I need to add a background picture to my web form. I want that the picture should be dynamically resized to the client area of the browser, when the page loads
How to do it using CSS? Similar TutorialsHi, is there any way to achieve this effect (pseudocode) with CSS? if (image width > 100) add property width="100" to all img tags ie. i want to make all images larger than 100 pixels scale down Hey all, I have a couple of related questions. First off, is there a way to automatically resize a div or any other element to be the size of the background image. Basically I am trying to do all my images in the stylesheet to allow for easy skinning. I've been doing stuff like: Code: #myDiv { background:url(graphics/cat.jpg); height:75px; width:75px;} But manually setting the height and width gets really tedious after a dozen or so images. And a related question: manually setting the size of a div doesn't seem to work if I have display set to inline. I get divs that are zero width and zero height. But when I remove that line it works fine, except that I'd rather they be inline elements for positioning purposes. Thanks in advance. Hello, I'm using jquery and the cycle plugin to cycle through a few images on my homepage inside a container.When i load the website at any browser size, it seems to do the proper thing. The problems arise when i try to make the browser bigger or smaller after that, it does funky things to the images. If you begin to scale the browser when the first image is displayed, it also seems to scale properly for that first image, but goes haywire after that. It pretty much does it in all browsers and i can't seem to figure out if it's something im not setting properly within css or if it have something to do with jquery and the cycle plugin. here's the website thus far: www.beaucoupla.com this is my first time writing code so please any help would be appreciated! Code: @charset "utf-8"; /* CSS Document */ #mainWrapper { /* background:#000 right top no-repeat; min-width:1000px; min-height:775px; border:0px; background-color:#000; */ padding: 0 0 0 1px; margin:0; top:0; left:0; width:100%; } .mainbar { position:absolute; top:0px; left:0px; display:none; visibility:hidden; width:78%; min-height:100%; height:auto; /*This works for IE7 min-height:775px; height:775px;*/ border-right: #FFF solid medium; } #imagelist { left:0; position:absolute; display:block; visibility:visible; /* width:auto; static size */ } #imagelist img { display:block; } #imagelist img.first { display:block; } .theimage { position:absolute; left:0; width:100%; /* Adding this works for IE7 */ /* height:775px; */ border-right: solid #FFF medium; } #podcast { /*right:303px; */ position:absolute; top:0px; left:0px; height:100%; } .about_info p { font-size:1.1em; } .contact_info, .about_info, .news_info { position:relative; margin-top:4em; margin-left:10%; width:78%; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:1.3em; color:#FFF; height:100%; } .contact_info #title, .about_info #title, .news_info #title { font-size:1.75em; padding-bottom:1.5em; color:#1ac089; color:#03c5d1; } .contact_info .heading { color:#c04141; font-size:1.2em; } .contact_info .mail { text-decoration:underline; } .contact_info a:hover { color:blue; text-decoration:underline; } .news_info .heading { color:#c04141; } body { /*width:1400px; height:775px;*/ padding:0; margin:0; border:0; background-color:#000; } #share td { padding-left:0.5em; } #share { margin-left:1.4em; margin-top:0; border-top:0; /* padding-top:5; */ font-size:0.65em; } .sidebar { position:relative; font-family:Arial, Helvetica, sans-serif; font-weight:bold; margin-left:78%; margin-top:1em; font-size:2em; color:#FFF; } ul { border:0; margin:2px; text-decoration:none; } li { list-style:none; } a { text-decoration:none; color:#FFF; } a.home:hover { color:#bc7bd4; } a.news:hover { color:#7bd488 } a.podcast:hover { color:#d47b88; } a.blog:hover { color:#d4cb7b; } a.about:hover { color:#7bd4c6; } a.contact:hover { color:#d4a37b; } a.twitter:hover { color:#33ccff; } a.myspace:hover { color:#999; } a.facebook:hover { color:#5b61d5; } I've had an issue in the past where the background image creeps, or hangs, when resizing the window. To explain what I mean, check out this page: http://ridersresto.com/ this is the background image: http://ridersresto.com/images/main_bg.gif when you slowly resize the image, you will notice the background image on both sides of the page closing and opening a 1px gap. here is the CSS for the BG image: Code: body { margin: 0; padding: 0; background-color: #131313; color: white; background-image: url(http://ridersresto.com/images/main_bg.gif); background-attachment: fixed; background-repeat: repeat-y; background-position: top center; } .frame { margin: 0 auto 0 auto; padding: 0; width: 778px; background-color: #000000; color: white; } Code: <body> <div class="frame"> </div> </body> Is there a more efficient way of accomplishing this effect? Hi I am designing a page in which I want to include a background image that is anchored to the bottom right of the screen. I have managed to do this, the only problem I am having is that due to the image being a big one (dimensions) when the user's screen is of a lower resolution such as 800 x 600, the image takes over most of the page's background which is distracting from the main content. My idea is to have the image resize based on the user's screen resolution. Is this a feasible solution and if yes, how can it be achieved? Thanks I have been asked to create a font resize on a website. I can do the basics of it but I'm running into a couple snags Question 1 In my stylesheet, I have: Code: #centerCol { float: left; color: #333; font-size: 10px; padding: 10px 10px 10px 15px; } And in my code I have a function that contains: Code: document.getElementById('centerCol').style.fontSize = '12px'; It works fine to resize the centerCol ID but what if I want to only resize the <p> tags in the centerCol ID? Question 2 Is there a way to resize without the use of Javascript? Everything I've found so far includes it. Here is the code for what is basically the masthead for the top of a web page. It uses tables, and expands and contracts to fit the browser as the viewer re-sizes. Quote: <table width="100%"> <tr> <td><IMG src="images/banner_left_end.gif"></td> <td width="100%" background="images/some_background.gif" align="middle" valign="center"> <!-- middle cell at 100% to push the left and right cells to the browser edges --> </td> <td><IMG src="images/banner_right_end.gif"></td> </tr> </table> What I would like to do is get rid of the table and use DIV tags and CSS to do this, but I'm having trouble figuring out how to push the left image to the left and the right image to the right to make it grow and contract as the browser re-sizes. How is this done? I have attached the file, If you Open a File using that, the Textarea was styled to go to 90% (<textarea style="width:100%;height:90%;"></textarea>) this is designed only to work in IE! Can someone please help me? Thank you, In advance Zero Alright, this seems to be tricky, but here's the story: I've got a photography gallery I made for a friend, and the last thing that needs to be taken care of is cross-browser compatability. I'm down to one problem of image resizing for thumbnails in IE. I've seen a few solutions, but none of them seem to work, so maybe I'm just doing things wrong, but then again no site has talked about resizing both horiz. and vert. For the site, any image thrown on the page needs to be resized to no greater then 105x100. But please, don't tell me to use PHP for this - I'm very attached to the fact that the entire site weighs in at under 300 lines. Thanks, Brian Ziemek Hi there! I am tweaking a WordPress template to fit a blog for a roleplaying game. The template is a three-column, fixed-width one. It looks fine on my tiny 17" monitor at work, but at home on my 22", the blog is very small and sits in the center of the page. (The content section is just 904px wide.) Is there a way to tweak the style.css file in order to give the columns percentage widths instead of absolute pixel widths, so that the center "content" area will resize properly according to the reader's resolution/monitor size/window size? I have some experience with CSS and I'm usually pretty good at tweaking pre-existing CSS to fit my needs, but this is something that's a bit beyond me. I can't put a direct URL in my post, but here's a snippet of the CSS file: Code: body, h1, h2, h3, h4, h5, h6, address, blockquote, dd, dl, hr, p, form{ margin: 0; padding: 0; } body{ font-family: Arial, Helvetica, Georgia, Sans-Serif; font-size: 12px; text-align: center; vertical-align: top; background: #fff url(); color: #fff; } h1, h2, h3, h4, h5, h6{ font-family: Arial, Helvetica, Georgia, Sans-Serif; font-size: 16px; } a{ text-decoration: underline; color: #08441e; } a:hover{ text-decoration: none; } a img{ border: 0; } abbr, acronym{ border: 0; } address, dl, p{ padding: 10px 0 0; } blockquote{ margin: 10px 10px 0; background: #fffada url(images/bg_blockquote.gif) no-repeat 5px 7px; color: #736926; } blockquote p{ padding: 10px 10px 10px 20px; } blockquote blockquote{ margin: 10px 20px; background: #fff; color: #333; } blockquote blockquote p{ padding: 10px; } code{ background: #f9f9f9; } dt{ font-weight: bold; } dd{ padding: 0 0 5px 15px; } hr{ clear: both; margin: 15px 0 5px; width: 100%; border: 0; height: 1px; text-align: left; background: url(images/bg_comment_bottom.gif) no-repeat; } small{ font-size: 10px; } input, textarea{ font-family: Arial, Helvetica, Georgia, sans-serif; font-size: 12px; padding: 2px; } input#author, input#email, input#url, textarea#comment{ border: 1px solid #cbb945; background-color: #fffadb; padding: 3px; } input#author, input#email, input#url{ margin: 0 5px 0 0; } #container, #header, #menu, #menu ul li, #menu ul li a, #pagetitle, h1, #syndication, .pagewrapper, .page, .wrapper, .narrowcolumnwrapper, .narrowcolumn, .content, .post, .entry, .browse, sidebar{ text-align: left; vertical-align: top; } #container{ margin: 0 auto; width: 904px; padding: 10px 0 0; } #header{ margin: 0 0 10px; float: left; width: 904px; height: 250px; background: url(images/bg_header.gif) no-repeat left bottom; color: #333; } #menu ul{ margin: 0; padding: 0 0 0 175px; list-style: none; } #menu ul li{ float: left; margin: 0 5px 0 0; font-size: 14px; font-weight: bold; background: url(images/bg_tab_right.gif) no-repeat right top; color: #ffffff; } #menu ul li a{ display: block; padding: 14px 20px 10px; text-decoration: none; background: url(images/bg_tab_left.gif) no-repeat left top; color: #ffffff; } #menu ul li a:hover{ text-decoration: underline; } #pagetitle{ clear: both; width: 904px; height: 250px; } } #pagetitle h1 a{ text-decoration: none; color: #fff; } .pagewrapper{ margin: 0 0 10px; float: left; width: 904px; background: #fff url(images/bg_page_bottom.gif) no-repeat left bottom; color: #333; } .page{ float: left; padding: 0 5px 5px; background: url(images/bg_page_top.gif) no-repeat; } .wrapper{ /* This wrapper class appears only on Page and Single Post pages. */ float: left; width: 500px; } .narrowcolumnwrapper{ margin: 5px 0 0; float: left; width: 500px; background: #fff url(images/bg_narrowcol.gif) repeat-y; } .narrowcolumn{ float: left; width: 500px; background: url(images/bg_narrowcol_bottom.gif) no-repeat left bottom; } .content{ float: left; width: 500px; background: url(images/bg_narrowcol_top.gif) no-repeat left top; } Thank you! I'm looking to basically replicate the design of Engadget. Not entirely, just the real basic design of it. I'm trying to figure out how to use 4 different images (a right header, left header, left footer, right footer) to construct a site that resizes in different browsers to look good. How do I do this? I'm familiar with CSS and html. I want to make the images in Fireworks and slice them, but after I do that and have the html how do I do things like using a wrapper? Thanks for any help you can offer. http://hmv.co.in/temp/html/boxes.html when the content of the box of either left and right boxes in the above page is diff... the boxes margin is also changed... how can i make both the boxes of the same siz so tht theres blank space in the box tht has less content I have a div centered in the middle of my page if i type a long paragraph between the two <div> tags it is all one line, and resizes the div, even though i have its width set to a fixed size? is there something im doing wrong? Im completely stumped thanks in advance hello people, im stuck. i have a simple layout in html, it works fine in html but when i try to use css to layout the page i cant get the centre cell to resize while the top and bottom don't. here is my html page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td height="52" bgcolor="#009999"> </td> </tr> <tr> <td bgcolor="#FF9933"> </td> </tr> <tr> <td height="52" bgcolor="#009999"> </td> </tr> </table> </body> </html> can anyone help? can css do this? Paul Sully the stuck Hey people. I've been desperatly searching for a fix for the bug in my CSS, but I don't know what I'm doing wrong. Here is a link to the the testfile: http://users.skynet.be/bert_fonteyn...iek/index.html. The page validates as valid XHTML. Now here is the bug in Windows (I have not tested it in Mac yet), both in Netscape 7 as in IE 6. Shrink your window, so you have a horizontal scrollbar. Scroll to the right, and you will notice there is a white area which can 't show the backgroundtile for some 60 px wide. The content (which is white) is there however... Can someone please tell me what I'm doing wrong? Greetz, Bert Anyone know how to get your website's background to resize as the page is manually resized when using IE? It resizes properly on both on mac and PC using Firefox, Safari, and Opera, but not IE (on PC). Thanks I fixed it on my own, thanks for the multitude of responses, not. Sup all. Im trying to make a website but it keeps resizing when I expand and retract me webbrowser. So Far this is my code PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Free UFC PPV</title> <style type="text/css"> body { background-color: #CCC; font-family: Tahoma; } #holder { width: 75%; padding: 10px; border: 1px solid; text-align: left; } #img{ background-image:url(images/header.png); } #login { width: 100%; font-family: Tahoma; font-size:15px; text-align: right; color: Black; border: 1px solid; } </style> </head> <body> <center> <div id="holder" style="width:75%"> <a href="index.php"> <img src="images/header.png" alt="Header Image" width="1024" height="150" /></a> <div id="login" style="100%" > <form action=""> Login:<input name="userlog" type="text" /> Password:<input name="passlog" type="text" /> <input name="btn_sub" type="button" value="Login" /> </form> </div> </div> </center> </body> </html> What can I do to stop resizing? I'm creating a site that works fine in FF. However, in IE, if I resize the window, the content doesn't move until I refresh the page. When I refresh the page, everything is centered again, but dragging IE to a new size, keeps everything in the same spot. Is there a fix for this? Unfortunately, I don't have the site posted, but may be able to throw it up somewhere if needed. Thanks. Edit: Nevermind. Had the body set to a certain width. Took that out and it works. |