I have an image of TV set and I want to place images of "shows" in it, centered horizontally on the screen (in front of the tv screen image). I'm using a to set the dimensions of the area in which to place the images, but I don't have to if it's not necessary. I've fiddled with position:absolute/relative of the and the images, but I can't get both images to be centered and stacked - either they partly overlap when centered or they align perfectly at the edge of the "". Here's the current iteration of the code. Any advice would be appreciated.
<div id="sourceDiv" align="center">
<img class="test" src="uvaCover.jpg" style="z-index:2; width:800px">
<img class="test" src = "tvScreen.jpg" style="z-index:1; width:900px">
</div>
.test {
position: absolute;
display: block;
margin:auto;
height:auto;
overflow: hidden;
}
#sourceDiv {
position:relative;
background-color: red;
top:170px;
left: 20px;
width:1000px;
height: 800px;
margin:auto;
}
I found the answer. For the ":
display: flex;
align-items: center;
justify-content: center;
I am using mPDF(v7.0) to create a PDF from my HTML. I want to create a PDF that contains an image, within a div (.container-sizing). I have to be able to have the ability to position the image within .container-sizing using CSS and zoom and flip the image.
I have tried the below:
CSS
.container-sizing {
overflow: hidden;
position: relative;
width:600px;
height:430px;
}
.img {
max-height: 100%;
position: absolute;
top: -100px;
left: -100px;
right: 0;
bottom: 0;
margin: auto;
transform:scale(1, -1);
}
HTML
<div class='container-sizing'>
<img src='images/my-image.jpg' alt='' class='img'/>
</div>
This doesn't work as it ignores overflow:hidden on the containing div - which is pretty essential when positioning the image. Instead, I tried styling the image as a background image, which works great but then I have run into problems with transform: scale(1, -1). Despite mPDF's documentation saying that this is supported, it doesn't seem to work when applied to a background image.
CSS:
.container-sizing {
width:600px;
height:430px;
overflow: hidden;
}
.img {
background-image: url('images/my-image.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
width:600px;
height:430px;
transform:scale(1, -1) ;
}
HTML:
<div class='container-sizing'>
<div class='img'></div>
</div>
Does anyone have any ideas how I can get this working to produce a pdf that shows the image how it is declared in the css?
Thank you!
After spending ages trying to figure this out, I ended up dropping mPDF and using domPDF instead as this supports the overflow: hidden property I needed. Just posting in case anyone else runs into a similar issue!
I have tried moving the id around and putting both first and second images as a backround. Why isn't it working?
HTML
<div class="brandsCarousel">
<ul>
<li class="logo"><img id="logo-gpjbaker"></li>
</ul>
</div>
CSS
a #logo-gpjbaker {
background-image: url(../images/logo-gpjbaker.png) center top no-repeat;
max-width: 150px;
}
a #logo-gpjbaker:hover {
background-image: url(../images/logo-gpjbaker2.png) center top no-repeat;
max-width: 150px;
}
The reason it it is not working is due to the space between your a and #logo-gpjbaker:hover
http://codepen.io/jonathan/pen/Jdaova
It should be, this with no space:
a#logo-gpjbaker:hover {
background: url(logo-gpjbaker2.png) center top no-repeat;
max-width: 150px;
display:block; /* add this */
height:50px; /* add this */
}
Since your id is on your anchor tag or just use #logo-gpjbaker:hover
Also try setting your a anchor tag to display:block so it fills the entire space of its parent. Which should be used anytime when using an anchor tag as a trigger since its default display is set to inline.
Don't forget to set your height property as well.
Try this
a#logo-gpjbaker:hover
or this
#logo-gpjbaker:hover
Here you have a better example: JSFIDDLE
I am currently designing a site using Bootstrap and am trying to include a full height background cover image like on this site: http://lewisking.net/.
This is my code:
HTML
<header class="title">
<div class="cut">
<img src="" height="">
</div>
<h2>Vintage Boutique Based in New York</h2>
<nav>
<ul>
<li>SHOP</li>
<li>ABOUT</li>
<li>PRESS</li>
</ul>
</nav>
</header>
CSS
header {
background: url(../img/nycfull.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.cut img {
max-width: 100%;
height: auto;
max-height: 100%;
}
However, I can't see to get the image to cover the entire "above the fold" section. The image just go as height as the text in the header. Any idea what I am doing wrong?
Do you mean like this demo ?
If yes try this code :
CSS CODE
.cover{
color: rgb(255, 255, 255);
position: relative;
min-height: 350px;
background: url("http://lewisking.net/images/header-image.jpg") no-repeat scroll 0px 100% / cover transparent;
}
nav ul li {
list-style:none;
float:left;
margin-right:50px;
}
HTML CODE :
<div class="cover">
<div class="clearfix"></div>
<nav>
<ul>
<li>SHOP</li>
<li>ABOUT</li>
<li>PRESS</li>
</ul>
</nav>
</div>
Your nav and header should not be together! Use your header to display your initial section for your site (what people see when they land on your page). Add positions to your nav to fix it where you want instead.
CSS code for a full height cover image:
header {
background-image: url(background-img.jpg);
background-repeat: no-repeat;
background-attachment: scroll;
background-position: bottom;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
min-height: /*enter value here*/;
}
In your HTML, you should code your <nav> navbar html here </nav> first, and then your <header> header html here </header>.
If you are coding your site to be mobile-ready, read this tutorial to implement a working cover image fix: CSS background-size: cover – Making it work for mobile / iOS
At the moment I have this image:
What I've been asked to do is to give it this effect:
Forget about the background color - notice the reflection of part of the image underneath, still the same color but with an opacity-style effect on it.
I have tried using opacity, and webkit-reflection in CSS3 but have had no luck.
I've now taken that code out as it doesn't work, I'm just left with the original image:
.infrareporting_host_0 {
background: url("../interface/infrareporting/hostLightGreen.png") no-repeat scroll 0 0 transparent;
}
Please remember:
I only want exactly what is shown - a lower section of the image reflecting, NOT the whole image reflecting
How can I fade the opacity of the reflected image ONLY? the normal one I want to stay the same but fade the reflection
A cross-browser solution is best (atm I can only do it in chrome)
Update
So far my code is reflecting properly in chrome only but opacity is not working correctly. I have this:
-webkit-box-reflect: below -3px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(.7, transparent), to(white));
you can do as following :
html :
<div class="image-block">
<img src="http://i.stack.imgur.com/mbf9p.png" alt="" />
<div class="reflection">
<img src="http://i.stack.imgur.com/mbf9p.png" alt="" />
<div class="overlay"></div>
</div>
</div>
css :
.image-block { width:78px; margin:0px 10px; float:left; }
.reflection { position:relative; }
.reflection img {
-webkit-transform: scaleY(-1);
-moz-transform: scaleY(-1);
-ms-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
filter: flipv; opacity:0.20;
filter: alpha(opacity='20');
}
.overlay { position:absolute; top:0px; left:0px; width:78px; height:120px;
background-image: -moz-linear-gradient( center bottom, rgb(255,255,255) 60%, rgba(255,255,255,0) 75%);
background-image: -o-linear-gradient( rgba(255,255,255,0) 25%, rgb(255,255,255) 40%);
background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.60, rgb(255,255,255)), color-stop(0.75, rgba(255,255,255,0)));
filter: progid:DXImageTransform.Microsoft.Gradient( gradientType=0, startColor=0, EndColorStr=#ffffff);
}
check live demo here : demo
You can use CSS 3 for it:
.reflect {
-webkit-box-reflect: below 0
-webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.5, transparent), to(white));
}
Or alternatives like this one:
http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/cross-browser-css-reflections-glows-and-blurs/
Use this code:
.infrareporting_host_0::before,
.infrareporting_host_0::after
{
content: "";
position: absolute;
top: 100%;
z-index: -1;
width: inherit;
height: inherit;
display: block;
}
.infrareporting_host_0::before
{
background: inherit;
}
For more info, see Crossbrowser CSS3 Reflections.