Vertical alignment - Firefox - css

It works in every browser, except firefox. The size of image is not fixed. I need to center vertically any image inside <a> tag.
HTML
<a href="#" class="tip popup">
<img src="http://3.bp.blogspot.com/-IjgG5GYb7SI/UNyqFqIOHkI/AAAAAAAAEd8/aoWhNyoSYiw/s1600/Toshiba+Lightfield+Module+AJ201212270055.jpg" alt="">
</a>
CSS
.tip img {
position: absolute;
min-height: 100%;
width: 100%;
border-radius: 2px;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.tip {
position: relative;
display: block;
height: 200px;
width: 100%;
border-radius: 5px 5px 0 0;
overflow: hidden;
margin-top: -14px;
margin-left: -14px;
padding-right: 28px;
}
http://fiddle.jshell.net/Pbe7m/3/

Try to give to an image:
img{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin:0;
}

Related

fixed header for print not taking full page width

I have a hidden header which is shown when printing a page, but when i try to print it with chrome 40 it's not taking the full width page. why?
HTML
<div id="header">
<img id="logo" src="assets/img/brand.png">
<div id="title">Departamento de diagnostico por imagenes</div>
</div>
<div id="footer">
<p class="page"></p>
</div>
CSS
#header{
top:0px;
right:0px;
width: 100%;
height: 45px;
position:fixed;
border:1px solid #ccc;
}
#logo{
position: absolute;
top: 0;
left: 0;
height: 46px;
}
#title{
position: absolute;
top: 0;
right: 0;
font-size: 18px;
font-weight: bold;
}
#footer {
position: fixed;
left: 50%;
bottom: 0;
/*right: 0;*/
height: 40px;
text-align: center;
}
#footer .page:after {
content: counter(page, upper-roman);
font-size: 18px;
}
UPDATE
I changed to position absolute, and it works, it's taking the full width
but now I realized that it's not repeating in every page, even with position fixed
Also notice the footer with number page, it's wrong centered because of fixed position, but when i change it to absolute it's correct but it goes to the bottom of the content, not of the page, and in the two cases neither repeat in every page
Remove the fixed position, add absolute instead, and I've also changed the height of #logo to 100% instead of 46px
SNIPPET
body {
font-family: Arial, sans-serif;
}
#header {
top: 0px;
right: 0px;
width: 100%;
height: 45px;
position: absolute;
border: 1px solid #ccc;
}
#logo {
position: absolute;
top: 0;
left: 0;
height: 100%;
}
#title {
position: absolute;
top: 0;
right: 0;
font-size: 18px;
font-weight: bold;
}
h3 {
margin-top: 100px;
}
#header-table {
top: 150px;
/*Change to 0px when supposed to use*/
right: 0px;
width: 100%;
height: 45px;
position: absolute;
border: 1px solid #ccc;
display: table;
}
#logo-cell {
position: absolute;
top: 0;
left: 0;
height: 100%;
}
#title-cell {
display: table-cell;
vertical-align: middle;
font-size: 18px;
font-weight: bold;
text-align: right;
}
<div id="header">
<img id="logo" src="http://img3.wikia.nocookie.net/__cb20140501181347/creepypasta/images/f/f6/Grumpy_Cat.jpg">
<div id="title">Departamento de diagnostico por imagenes</div>
</div>
<h3>Display: Table, if your title should be vertically centered</h3>
<div id="header-table">
<img id="logo-cell" src="http://img3.wikia.nocookie.net/__cb20140501181347/creepypasta/images/f/f6/Grumpy_Cat.jpg">
<div id="title-cell">Departamento de diagnostico por imagenes</div>
</div>

display image on middle of div

I was looking the way to create image view as have Facebook or Google Plus but i can't put the image at middle of div.
This is my code:
.overflow {
background-color: rgba(0,0,0,.9);
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.overflow .left-img-box,.overflow .right-content-box {
display: inline;
height: 100%;
}
.overflow .left-img-box {
display: block;
left: 0;
margin: auto;
position: absolute;
text-align: center;
top: 0;
vertical-align: middle;
width: 70%;
}
.overflow .right-content-box {
background: #fff;
position: absolute;
right: 0;
top: 0;
width: 30%;
}
.overflow .left-img-box img {
margin: auto;
max-height: 100%;
}
You can see the example: http://fiddle.jshell.net/N6md8/5/
You can do something css like:
img {
margin:auto;
position:absolute;
top:0;
left:0;
bottom:0;
right:0;
max-height:100%;
max-width:100%;}
reference: http://codepen.io/shshaw/full/gEiDt
I beleive you can go with position:fixed as well :)

Sticky footer at the bottom

I'm having trouble with my footer, it's not being pushed by the content, I already tried to substitute absolute to relative, but with no success, I'm trying to use bottom:0; but it's not working either, here is my css code:
html, body {
width:100%;
min-height:100%;
background-image: url(../img/bg.png);
background-repeat: repeat;
}
* {
margin: 0px;
padding: 0px;
}
a, img {
border:none;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
}
#wrapper {
width: 1024px;
margin-right: auto;
margin-left: auto;
min-height: 100%;
position:relative;
}
#foot {
width: 100%;
height:200px
position:absolute;
bottom:0;
background-image:url(../img/foot.png);
background-repeat:no-repeat;
}
#banner {
min-height: 100%;
margin:0;
padding:0;
position: relative;
top: 24px;
background-image: url(../img/banner2.png);
background-repeat:no-repeat;
width:100%;
height:173px;
}
#navigation {
height: 60px;
position: relative;
left: auto;
width: 100%;
top: 23px;
margin: 0px;
padding: 0px;
z-index:1;
border: none;
}
#categoria {
position: absolute;
width: 710px;
height: 240px;
z-index: 0;
left: -29px;
top:30px;
padding: 0px;
z-index:1;
}
.othergames{
position: absolute;
top: -13px;
width: 740px;
height: 251px;
background-image: url(../img/otherg.png);
background-repeat: no-repeat;
z-index:1;
left: -43px;
}
.othergames-back{
position: absolute;
top: -11px;
width: 730px;
height: 247px;
background-color:#FFF;
left: -37px;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
#texto{
height: 10px;
text-align:center;
width: 50px;
margin: 0px;
padding: 0px;
left: 34px;
top: 243px;
}
#apDiv1 {
position: absolute;
left: -3px;
top: 3px;
width: 209px;
min-height: 100%;
z-index: -1;
margin: 0px;
padding: 0px;
}
#like {
position: relative;
left: -3px;
top: 550px;
width: 215px;
min-height: 100%;
z-index: -1;
margin: 0px;
padding: 0px;
}
#apDiv2 {
position: absolute;
left: 220px;
top: 60px;
width: 862px;
height: 482px;
z-index: 0;
padding: 0px;
}
#apDiv4 {
margin: 0;
padding: 0;
position: absolute;
left: -6px;
top: 90px;
width: 201px;
height: 499px;
z-index: 1;
}
And the html code:
<div id="wrapper">
<div id="banner"></div>
<div id="navigation">
<div id="apDiv4">
</div>
<div id="fb-root"></div>
<div id="like">
<div class="fb-like-box" data-href="https://www.facebook.com/pages/Legend-of-Games/476628629090111" data-width="215" data-show-faces="true" data-stream="false" data-show-border="false" data-header="false"></div></div>
<div id="apDiv2">
<script>
(function($){
$(window).load(function(){
$("#apDiv2").mCustomScrollbar();
});
})(jQuery);
</script>
<div align="center" id="thumb">
<div id="screen_game">
<img style="border-radius:5px;border:thin solid #FFF;" src="../legendofgames/documentos/games/<?php echo $row_GameData['strImage']; ?>" width="160" height="130"/>
<div align="center" id="gametext"><?php echo $row_GameData['strNome']; ?> </div>
</div>
</div>
<div id="apDiv1"><img src="../img/lateralb2.png" width="209" height="592"/>
</div>
</div>
</div>
<footer >
<div id="foot"></div>
</footer>
</body>
Since you had some background images and content that weren't available, I generated and inserted some into a <section> with an ID of container. As you can see in the fiddle, I have just set up the footer as a fixed position block element at bottom: 0;, which means that it will always be at the bottom.
CSS:
footer {
width: 100%;
position: fixed;
bottom: 0;
background: green;
}
Have fun with the rest of the page!
I think you need to change your position to fixed.
#foot {
width: 100%;
height:200px
position:fixed;
bottom:0;
background-image:url(../img/foot.png);
background-repeat:no-repeat;
}
I can't test your code but I was able to get a sticky footer using a similar styling.

How to add a responsive image using pseudo-elements

I try to add a box shadow and a gradient border using images and css pseudo-elements.
I tried that code:
.box:before {
content: url('box-shadow.png');
position: absolute;
width: auto;
height: auto;
max-width: 100%;
z-index: -1;
bottom: -9px;
line-height: 0;
}
.box:after {
content: url('box-border.png');
position: absolute;
width: auto;
height: auto;
max-width: 100%;
bottom: -5px;
right: 0px;
}
But the added images don't resize when the parent div resizes, whereas it works by adding the image manually.
See that fiddle http://jsfiddle.net/5TG3E/2/
I try from my side may be that's help you. Write like this:
.box:after {
content:'';
position: absolute;
z-index: -1;
bottom: -9px;
margin: 0 auto;
top:0;
left:0;
right:0;
background:url('http://dl.dropbox.com/u/4812171/box-shadow.png') no-repeat bottom center;
-moz-background-size:100% 9px;
background-size:100% 9px;
}
.box:before {
content:'';
position: absolute;
bottom: 0px;
right: 0px;
left:0;
top:0;
background:url('http://dl.dropbox.com/u/4812171/box-border.png') no-repeat bottom right;
}
Check this http://jsfiddle.net/5TG3E/6/

CSS need div to extend it's containers width

This is my current HTML structure. The footer div is sitting alone in the BODY.
<div id="footer">
<div class="container">
<div id="footer-bg">
<div class="footer1">
<p class="p1">asd</p>
<p class="p2">asd</p>
</div>
<div class="footer2">
<p class="p1">asd</p>
<p class="p2">asd</p>
<p class="p3">asd</p>
</div>
<div class="footer3">
<p class="p1">asd</p>
</div>
</div>
</div>
</div>
Here's the CSS for it:
#footer
{
position: relative;
background: url('../footer-bg-repeat.jpg') repeat-x;
height: 307px;
}
#footer #footer-bg
{
background: url('../footer.jpg') no-repeat top left;
height: 528px;
width: 1587px;
position: absolute;
left: -380px;
top: -221px;
}
#footer .footer1
{
position: absolute;
top: 137px;
}
#footer .footer1 .p1
{
position: absolute;
left: 500px;
background: #dcdcdc;
height: 23px;
width: 80px;
text-align: center;
line-height: 25px;
font-weight: bold;
}
#footer .footer1 .p2
{
position: absolute;
left: 1000px;
top: -20px;
background: url() no-repeat top right;
height: 40px;
width: 249px;
text-indent: -9999px;
z-index: 6;
}
#footer .footer2
{
position: absolute;
top: 159px;
height: 23px;
width: 100%;
background: #000;
}
#footer .footer2 p
{
display: inline;
line-height: 25px;
color: #636466;
height: 23px;
}
#footer .footer2 .p1
{
position: absolute;
left: 500px;
background: url() no-repeat center right;
width: 175px;
}
#footer .footer2 .p2
{
position: absolute;
left: 700px;
background: #dcdcdc url() no-repeat 60px 8px;
width: 75px;
padding-left: 15px;
}
#footer .footer2 .p3
{
position: absolute;
left: 800px;
}
#footer .footer3
{
position: absolute;
top: 190px;
}
#footer .footer3 .p1
{
position: absolute;
left: 500px;
width: 1000px;
}
I'm trying to get .footer2 and .footer3 to extend the width of the container allowing me to have a background colour set for what ever width the screen may be.
Setting 100% width just gets it to the size of the container - As I'd expect. How can I, though, get it to the width of the page?
Try setting both left and right property to 0;
you didn't define question well.
if you want to set it in middle set margins
margin:0 10px;
width:%your pages width%;
if you mean something else download Firebug plugin for Firefox and inspect a page's footer that did what you want to do and take a look at structure and css rules. it always works

Resources