CSS zoom - with static border width - html

Can it be done - crossbrowser (IE9, Mozilla, Chrome, Opera) ?
In this snippet .box border is affected by zoom property. Can this be avoided ?
<!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></title>
<style type="text/css">
.box {
zoom: 3;
-moz-transform: scale(3); /* FF fix */
border: 1px dotted black;
padding:10px;
}
</style>
</head>
<body>
<div class="box">content</div>
</body>
</html>

I'm not really sure what you expect here. If you apply the zoom property to any element, then all of it's measurements will be transformed by 1/x. Away your example, the best way to do this would be to divide the intended measurements by the value of your zoom. In your example, if you wanted to keep padding at 10px (or thereabouts), you'd use padding:3px instead.
However, because your issue is with the border property and specifically, having set 1px as the value, you can't divide this by your zoom value. Instead, you're going to have to wrap HTML around it:
<div class="border">
<div class="box"></div>
</div>
And move your border styling from .box to .border
Working Fiddle

Related

Make div full size of window with NO margin

I hate to even ask something that seems so dumb but I just dont get this. All I want to do is have a blue div at the top of my window that stretches across the entire window. I thought width:100%; would do just that but its leaving gaps around the edges for some reason.
My html:
<!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>Untitled Document</title>
<link href="_css/wikiToolBox.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="iWikiTopPanel" class="iWikiTopPanel"></div>
</body>
</html>
My css:
#charset "utf-8";
/* CSS Document */
.iWikiTopPanel{
width:100%;
height:200px;
background-color:#205081;
margin:0px;
border-bottom: 1px solid #2e3d54;
clear: both;
float:left;
}
body{
padding:0px;
/*set This thinking it might fix the issue, it didnt*/
}
Here's a pic of what I end up with:
And here's the element as seen in Chrome's element inspector:
I dont get it. So where is the padding/margin coming from and how do I get rid of it?
Try:
body{
margin:0;
}
You have a margin against your <html> tag.

Pin an input to bottom of page

I've been scratching my head over this for the last few hours. I'm trying to make an input field that stays put at the bottom of the page, similar to the Omegle chat bar.
I've set my height to 100% (well, 99, because if it's set to 100 the page has unnecessary scroll bars) and set the CSS bottom property to 0, but no matter what I try, the bar stays floating around 10% down the page.
My CSS code is:
html {
height:99%;
width:99%;
}
input.chatbar {
bottom:0;
width:90%;
height:5%;
outline:none;
resize: none;
border:none;
border-bottom:#000 medium solid !important;
}
and my HTML code is
<!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>Global Chat</title>
</head>
<body>
<input class="chatbar" />
</body>
</html>
and here is a JSFiddle of it.
I want it to float above the page and scroll with the user, like the Omegle bar. How would I do this?
Sorry, I know this is a basic question, but I can't find the answer anywhere else.
Add position: fixed; to the css
Also be careful about the percent heights. Check out min and max height properties

image width and height seems wrong when getting it with CSS

I'm not so good at CSS design, but I'm just working on a content display layout for a website.
I basically wanna make a thin line by putting an image inside a container div. and set all dimension properties as below.
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<style>
#thinLineWrap{
width: 510px;
height: 3px;
background-color: #000000;
}
#thinLineWrap img{
width: 170px;
height: 3px;
background-color: #000000;
margin-top: 0px;
float:left
}
</style>
</head>
<body>
<div id="thinLineWrap">
<img src="images/thin_line.gif" border="0">
</div>
</body>
</html>
But when viewing the output in Chrome inspect, the output result couldn't seem to have the specified sizes as expected, as illustrated in the snapshot below.
You might also notice that my image width and height became 171px and 4px respectively, unlike what it was set in the stylesheet section.
Any possible mistake I might have done? Why did the image element become 1 pixel bigger than it should be?
any advice would be very appreciated.
EDIT:
A copy of the original problematic thin line image is here. Not sure if there could be anything wrong with the image itself.
https://lh5.googleusercontent.com/-kDRsR493dZU/UMOXRBbty9I/AAAAAAAAAh8/g58GnqQZ3pk/s128/thin_line.gif
You defined an Img within the #thinlinewrap to have the properties.
div#thinLineWrap{
border:0px;
}
#thinlineWrap img{
height:3px;
}
Might be the code you are looking for.
i found it out.you'r img inherited it's border from another style ,try overriding it like this :
#thinLineWrap img{
border:none;
width: 170px;
height: 3px;
background-color: #000000;
margin-top: 0px;
float:left
}

How to make IE respect max AND min-width [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to make IE support min-width / max-width CSS properties?
I have a site that has it's main navigation in a list (floated left).
The li elements need to have a min AND max width.
This css of course works fine in all good browsers.
But IE (9) doesn't react to it.
ul.dropdown li {
line-height: normal;
text-align: center;
max-width: 145px;
min-width: 88px;
min-height: 30px;
}
If I use this code on one condition, for example max width IE respects it.
http://perishablepress.com/maximum-and-minimum-height-and-width-in-internet-explorer/
But of course I can't use the same for min-width.
I need a solution that IE respects max AND min width.
Is there a solution?
Thank You!
edit: I forgot to mention i already added
<!DOCTYPE html>
;)
Ok, I found the problem.
It wasn`t in the code, my IE just automatically switched into Quirks mode.
Changed it by going in the console (F12) and changed the Document Mode to IE9!
Thank You!
Try this (it's work on my ie8)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>template</title>
<style type="text/css">
#content{
height:400px;
background:yellow;
*width: expression(if(document.body.clientWidth < 534){"533px";}else if(document.body.clientWidth > 776){"777px";}else{ "auto"; }); /* set min-width for IE */
background: red;
}
</style>
</head>
<body>
<div id="content">
hello
</div>
</body>
</html>
I don't know how to write this with ? and :.
Hack width with this : http://paulirish.com/2009/browser-specific-css-hacks/

CSS Percentage Bars

I am trying to make a SIMPLE Css percent bar.
OK go to http://htmledit.squarefree.com/
and copy/paste this in it:
<!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" xml:lang="en" lang="en">
<head>
<style>
#perc {
width:667px;
border:4px solid blue;
}
#perc_in {
width:100%;
padding:3px;
font-size:17pt;
background:red;
margin:3px;
}
</style>
</head>
<body>
<div id="perc"><div id="perc_in">100%</div></div>
</body>
</html>
As you can see the red inside bar is overlapping the blue border... why? :\
By the W3C box model, margins and padding add to the width of a <div>. So instead of 100%, the width becomes more than that, and causes the progress bar to overflow the blue border.
You'll have to change the 3px margin of #perc_in to a 3px padding on #perc, and remove the padding on #perc_in.
Here is the updated code (added by Blaenk):
#perc {
width:667px;
border:4px solid blue;
padding:3px;
}
#perc_in {
width:100%;
font-size:17pt;
background:red;
}
The reason is: W3C box model. It says that final width of an element is a sum of width and padding properties. So if you declare that element suppose to have width: 100% (to be exact: 667 pixels in this case) and also declare that element should have 3-pixel padding from left and right (total: 6 px) the final width of the element is: 667 + 3 + 3 = 673 pixels.