问题
I am writing a website intro page and really like the style on this page: http://www.davidhutton.com/ where there are moving images/video in another image like that.
To simplify it how is it that I can put an image in the TV container here: http://jsfiddle.net/h9Nn3/2/
I am not sure how complicated it is but it is overly complicated at least a starting point would be greatly appreciated!
回答1:
According to your example you could solve it like this:
<style>
div.container {
width: 337px;
height: 297px;
padding: 25px 35px 0px 28px;
background: url(http://www.officialpsds.com/images/thumbs/tv-screen-1-psd29071.png) no-repeat 0 0;
}
div.container > div {
height: 189px;
overflow: hidden;
border: 1px solid red;
}
</style>
<div class="container">
<div>
This container should have a red border and fit's exactly the screen.
You can replace or fill it with everything you want, for example an img-tag.
</div>
</div>
回答2:
I'd actually set the TV image as a background image and position your other image inside the same container.
<div id="content">
<img src="https://www.google.com/images/srpr/logo3w.png" />
</div>
#content {
background-image: url('http://www.officialpsds.com/images/thumbs/tv-screen-1-psd29071.png');
width: 373px; /* 400 - 27 for padding */
height: 294px; /* 322 - 28 for padding */
padding: 27px 0 0 28px;
}
DEMO
回答3:
Well it's quite simple actually. You can use Chrome's right click > "Inspect Element" or FireFox equivalent to see that there is an image of a tv (as you've done) and a sliding images element that is:
position: absolute;
top: #px;
left: #px;
You can test this html/css with a simple image before you tackle the sliding images via jQuery or JavaScript
来源:https://stackoverflow.com/questions/11109847/how-to-embed-images-or-video-in-a-preset-images