<div> height rendering issue with Firefox - firefox

I created a div that transitions from a beginning height to a larger height, revealing a list. It looks fine in web-kit browsers but in Firefox the div appears to come up short, cutting off the bottom of the list.
I tried setting the div height in em hoping that the div would then match the height to the font size used in the list. Still the same thing occurs.
Any ideas?
CSS:
#nav{
padding:0;
position:fixed;
top:27px;
left:27px;
font-family:arial;
font-size:10px;
background-color:#ccc;
width:11.3em;
height:5.5em;
overflow:hidden;
transition: height .5s;
-webkit-transition: height .5s; /* Safari */
}
#nav:hover{
height:22em;
}
#nav a.bg:hover{
background-color: #ccc;
}
#nav a{
text-decoration:none;
color:#000;
}
#nav a:hover{
background-color:#6a6a6a;
}
HTML:
<div id="top">
<div id="nav">
<!--logo_image-->
<a class="bg" href="#"><img src="b&w_logo.jpeg" height="56" width="110" /></a>
<!---->
<div style="height:1em;"></div>
<div style="font-size:1.1em;"><b>Artists</b></div>
<div style="height:1em;"></div>
<div>Ahnnu</div>
<div>Gem Vision</div>
<div>Dope Body</div>
<div>Co La</div>
<div>Teenage Souls</div>
<div>Kid Krusher</div>
<div>Lil Jabba</div>
<div>Cex</div>
<div>Teeth Mountain</div>
<div>Jimmy joe Roche</div>
</div>
</div>

U have 2 options I think:
One is called CSS reset - http://html5reset.org/
The second one is called Normalize. Instead of resetting all styles, it targets the ones that need to change to give you sane, consistent results across browsers in a smaller file size. http://necolas.github.com/normalize.css/

Related

Dompdf Why When you go to second page the text goes to the left

I have a simple pdf that I created with dompdf div and css.
#menu{
width:600px;
float:left;
margin-top:10px;
font-weight: bold; }
#Istarih{ float:left; width:180px; margin-right:0px; font-weight: bold; }
#Isdeneyimi{
float:left;
width:500px;
word-wrap:break-word;
margin-right:0px; }
.clear
{
clear:both;
height:10px;
}
<div>
<div id="menu">WORK</div>
<div class="clear"></div>
<div id="Istarih">2002</div><div id="Isdeneyimi"><b>WORK</b><br>WORK<br><br> blblablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablaablabla <br></div><div class="clear"></div>
</div>
When you go to second page the text goes to the left
How can I solve this problem?
Dompdf Long Text Problem
On the second page the first floated element is no longer present and thus no longer impacts the second element. With this particular layout, if you wanted to maintain the margin all the way through the document you would want to style the second element differently. Remove the float from that element and give it a margin equal to the space occupied by the floated element.
#Isdeneyimi {
width:500px;
word-wrap:break-word;
margin-right:0px;
margin-left: 180px;
}
Margins of in-flow elements adjacent to floated elements overlay the flow. The above styling will have the same effect as floating siblings but will maintain the margin across pages.

Align 2 sections next to each other in responsive

I want to align 2 sections next to each other. One has text(heading) and the text will be changing in length. one more section has a image.
My issue is when i make the screen size smaller, the second section is coming down.
Tried display:table-row; display:table; display:table-cell; nothing helps. the second div still comes down.
Please Help.
-Thanks in advance.
This is my code:
HTML
<h2><span>BE PREPARED PREPARED</span><img src="http://localhost/safesteps/wp-content/uploads/2014/04/before_bg_r.png" alt="before_bg_r"/></h2>
CSS
.inner_berfore h2{
display:table-row;
border-top: 4px solid #767676;
position: relative;
float:left;
width:98%;
}
.inner_berfore h2 span{
background:#767676;
display:table-cell;
font-family: 'arial-black';
text-transform:uppercase;
padding-left:16px;
font-size:22px;
line-height:40px;
color:#FFF;
float:left;
}
.inner_berfore h2 img{
display:table-cell;
float:left;
height:40px;
}
For static Text:
Try : http://jsfiddle.net/lotusgodkk/anK6u/6/
div{display:inline-block;width:49%;vertical-align:top;}
div img{max-width:100%}
HTML:
<div>Text</div>
<div><img src="src" /></div>
you can assign different width as per your design
For dynamic text:
http://jsfiddle.net/lotusgodkk/anK6u/8/
CSS:
.table{display:table;}
.table div{display:table-cell;vertical-align:top;}
.table div img{max-width:100%}
HTML:
<div class="table">
<div>Hellodfgsdfgsdfghsdfhsdfhdsfhdfhdsfhsdfhsdh</div>
<div>
<img src="http://asia.olympus-imaging.com/products/dslr/e520/sample/images/sample_03.jpg" />
</div>
</div>

How to auto center an img inside a div regardless of browser window size?

I have a html document structured with a header, content, and footer divs. I am trying to center an image (a logo) inside my header div to display at the top of my webpage in the middle. I can absolute position it into the middle, but when I change the browser size, the img doesn't move along with it. I want it to be place automatically in the center of the window. I am stumped..?
I have tried , margin-right:auto; margin-left:auto. I have also tried the trick where you make margin-left negative half the width and top 50%, but nothing has worked so far.
html:
<body>
<div id="container">
<div id="header">
<img id="logo-img" src="http://f.cl.ly/items/3c0h1b0F3t1D1S1T2J0F/smallersticker.png">
</div>
/*...(body div)
...(footer div)*/
</div> /*container*/
css:
#header {
background-color:transparent;
height:260px;
width:100%
}
#logo-img{
display: block;
margin-left: auto;
margin-right: auto;
}
Also, Do I even need a container? Not sure if I need javascript for this, or if it can be accomplished with just html/css? Hope someone can help, thanks!
What is happening is that you are already correctly centering your image.
Your problem is that the image is huge. If you notice closely, the image is not centered if your browser window becomes smaller in width than the image.
Remove the white area from the image and it will center correctly.
Edit: in IE, you need to add the rule text-align:center to #header
Another way:
If you don't want to change your image, you can use this hack:
<style>
#header {
overflow-y: hidden;
background-color: transparent;
height: 260px;
width: 100%;
margin-left: 50%;
}
#logo-img{
display: block;
position: relative;
right: 50%;
}
</style>
<body>
<div id="container">
<div id="header">
<img id="logo-img" src="http://f.cl.ly/items/3c0h1b0F3t1D1S1T2J0F/smallersticker.png">
</div>
/*...(body div)
...(footer div)*/
</div> /*container*/
I learned this hack a while ago here
Just use the logo at a size it's supposed to be (like this here), then all you need to do is add the align="center" attribute to your logo's div.

Responsive Image Adds Spacing

For some odd reason I added a responsive image to my responsive layout and it seems to add some sort of spacing below the image.
You may view the issue here: http://www.client.noxinnovations.com/jensenblair/
The top image. Here is my HTML and CSS.
HTML
<div class="header"> <img src="images/photograph.jpg" /> </div>
CSS
img {
max-width: 100%;
height: auto !important;
}
.header {
height: auto;
padding: 0;
margin: 0 auto;
border: none;
}
It seems to be consistent in each browser. Any ideas anyone?
There are two ways (that I know of) to solve this: http://jsfiddle.net/3kC4K/1/
<div>
<img src="http://placehold.it/100x100/"/>
</div>
<div>
<img src="http://placehold.it/100x100/" class="block"/>
</div>
<div>
<img src="http://placehold.it/100x100/" class="inline"/>
</div>
CSS
div{
border:solid 1px #f00;
margin:5px;
float:left;
}
.block{
display:block;
}
.inline{
vertical-align:bottom;
}​
img tags, by default, are inline elements. Because of this, browsers will create a sort of "gutter" underneath them so that any text that wraps below it won't be flush with the bottom of the image.
In your case, simply applying display:block to the image should do the trick.

firefox issue with the padding-right of the container box

there's a container with background-color and padding specified. there's an image inside it. in a full screen browser window it looks like as it should look like:
http://img263.imageshack.us/img263/4792/61536769.png
but after resizing the window (window width is less than the content width) and the horizontal scrollbar appears, if i scroll it right, i can see the background ends where the window ends:
http://img845.imageshack.us/img845/7370/11506448.png
here's the code:
<body style="margin: 0; padding: 0; overflow-y: scroll;">
<div style="background: pink; padding: 32px; display: block;">
<img src="http://projects.quantize.com/P/reporter/blog/wp-content/themes/thesis/rotator/sample-1.jpg" style="width: 640px;" />
</div>
</body>
in ie8 it looks right, the padding is treated as it's part of the content. in firefox and in opera it isn't, even if i use the "-moz-box-sizing: border-box;" (and correct doctype and everything...) so i don't really know what should i do. i usually did it with margin for the image but this time that can't be a solution (the actual thing is different than this example, but it shows the exact problem).
thanks for your help in advance :)
Add an extra div that wraps your existing div and do float:left.
<body style="margin: 0; padding: 0; overflow-y: scroll;">
<div style="background-color: pink; width:100%;float:left;">
<div style="background: pink; padding: 32px; float:left;">
<img src="http://projects.quantize.com/P/reporter/blog/wp-content/themes/thesis/rotator/sample-1.jpg" style="width: 640px;" />
</div>
</div>
</body>
Edit: Removing display: block; as that's irrelevant when you have float.
What's going on is that the div isn't expanding to wrap around the image, since the image has a fixed width, but the div doesn't (and is therefore defaulting to 100% of the parent, which is body/html at 100% of the viewport). If you look at it with Firebug, you can see that the image is going outside of the bounds of the div and its padding.
I've tweaked the CSS in this jsFiddle to get the background to expand to the image. It should at least get you started. Basically, what I did was add overflow-y: auto; to the div, which expanded the background.
One thing you can do in this case is to put a specific width on the div as well:
<body style="margin: 0; padding: 0;">
<div style="background: pink; padding: 32px; display: block; width: 640px;">
<img src="http://projects.quantize.com/P/reporter/blog/wp-content/themes/thesis/rotator/sample-1.jpg" style="width: 640px;" />
</div>
</body>
You can do that in this case because you already know the width of the contents. Of course, if you need a dynamically sized div this might not work for you.
I was going to suggest putting margin: 32px on the image instead of padding: 32px on the div, but when I tried it that didn't help either. Bizzare.

Resources