I want to put the iframe inside a phone image. Phone image is .png and has a transparent background.
I don't know how to mask iframe and make it visible only inside the phone image.
.phone {
display: block;
position: relative;
right: 0;
bottom: 0;
float: right;
border: 1px solid red;
}
.phone > img {
width: 250px;
position: absolute;
}
.wrapper {
position: absolute;
top: 0;
}
<div class="phone">
<img src="https://i.ibb.co/y8HRgg4/phone-front.png">
<div id="wrapper">
<div class="phone view_2" id="phone_1">
<iframe src="https://onsen.io/samples/" id="frame_1"></iframe>
</div>
</div>
</div>
Here's a start. I've applied border radius to mask the iframe's corners, disabled pointer events on the image, and set scroll on the iframe's x-axis. Notice also that the image falls after the iframe in the document so it appears over the top of the iframe.
.wrapper {
display: inline-block;
position: relative;
width: 250px;
height: 600px;
overflow: hidden;
}
.wrapper > img, .wrapper > iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.wrapper > iframe {
overflow-x: auto;
border-radius: 60px;
}
.wrapper > img {
pointer-events: none; /* stop click & scroll on the image */
}
<div class="phone">
<div class="wrapper">
<iframe src="https://onsen.io/samples/" id="frame_1"></iframe>
<img src="https://i.ibb.co/y8HRgg4/phone-front.png">
</div>
</div>
try this
<iframe src="https://i.ibb.co/y8HRgg4/phone-front.png" frameborder="0"></iframe>
Related
I have to set a Vimeo as background for a div which is containing CTA box.
I found some example and made it possible to have the video background fullscreen and responsive as I needed.
But I found that the CTA box inside and the button are not clickable because of the "z-index" used to get the video back in the div.
play with z-index
moving element back and forth
.vimeo-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display:flex;
pointer-events: none;
overflow: hidden;
}
.vimeo-wrapper iframe {
width: 100vw;
height: 56.25vw; /* Given a 16:9 aspect ratio, 9/16*100 = 56.25 */
min-height: 100vh;
min-width: 177.77vh; /* Given a 16:9 aspect ratio, 16/9*100 = 177.77 */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}.content{
display:flex;
align-items:center;
justify-content:center;
z-index:1;
flex-wrap:wrap;
}.content,h2{
width:100%;
text-align:center;
color:white;
}
.CTA-wrapper{
border:2px solid white;
width:30%;
padding-bottom:2%;
}
div button:hover {
color: yellow;
}
<div class="vimeo-wrapper">
<iframe src="https://player.vimeo.com/video/342964528? background=1&autoplay=1&loop=1&byline=0&title=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div class="content">
<div class="CTA-wrapper">
<h2>CTA Header</h2>
<button class="btn-success">Click Me</button>
</div>
</div>
</div>
expected: clickable inside elements, fullscreen and responsive background video
result: not the clickable inside element
.CTA-wrapper{
position: relative;
z-index: 9999;
}
I think it will work
css
.vimeo-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display:flex;
pointer-events: none;
overflow: hidden;
}
.content,h2{
width:100%;
text-align:center;
color:white;
}
.CTA-wrapper{
border:2px solid white;
padding-bottom:2%;
}
.vimeo-wrapper-box {
width: 100%;
}
div button:hover {
color: yellow;
}
.iframe_wrapper {
position: relative;
padding-bottom: 56.25%;
}
.vimeo-wrapper iframe {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0px;
width: 100%;
height: 100%;
}
.vimeo-wrapper .content {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
text-align: center;
}
HTML
<div class="vimeo-wrapper">
<div class="vimeo-wrapper-box">
<h1>dfghfh</h1>
<div class="iframe_wrapper">
<iframe src="https://player.vimeo.com/video/342964528?background=1&autoplay=1&loop=1&byline=0&title=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div class="content">
<div class="CTA-wrapper">
<h2>CTA Header</h2>
<button class="btn-success">Click Me</button>
</div>
</div>
</div>
</div>
</div>
I render a div with an image that looks like it's a video (but it's just an image, for performance). When the user clicks on the image, JS swaps out the image with the appropriate youtube embed code and plays the video.
Below the image/video div, I have another div with some action icons (share, like etc). Rather than have the actions below the image/video div, I'd like to put them over the image/video div on:hover. See below image for better description:
Here's the current structure of my code.
The HTML:
<div class="youtube-container col-sm-6 col-lg-4">
<div class="youtube-player" data-id="<%= trailer.youtube_id %>">
<div class="holder">
</div>
</div>
</div>
<div class="row icons">
<div class="icon">
<img src="icon1">
</div>
<div class="icon">
<img src="icon2">
</div>
<div class="icon">
<img src="icon3">
</div>
</div>
CSS:
.icons img {
height: 35px;
margin: -10px 0 0 5px;
}
.icons {
float:left;
margin: 30px 10px 10px 10px;
}
.icon img {
height: 55px;
}
.youtube-container {
display: block;
margin: 20px auto;
width: 100%;
width: 100%;
}
.youtube-player {
display: block; width: 100%; /* assuming that the video has a 16:9 ratio */
padding-bottom: 56.25%;
overflow: hidden;
position: relative;
width: 100%;
height: 100%;
cursor: hand;
cursor: pointer;
display: block;
}
img.youtube-thumb {
bottom: 0;
display: block;
left: 0;
margin: auto;
max-width: 100%;
width: 100%;
position: absolute;
right: 0;
top: 0;
height: auto
}
div.play-button {
height: 72px;
width: 72px;
left: 50%;
top: 50%;
margin-left: -36px;
margin-top: -36px;
position: absolute;
background: url("http://i.imgur.com/TxzC70f.png") no-repeat;
}
#youtube-iframe { <--- the iframe dynamically generated when someone clicks the image
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
After the page is loaded, Javascript goes through and 1) finds all the .holder divs 2) inserts a dynamically generated image 3) Adds an on.click event listener to .holder that, when clicked, swaps the image for a youtube iframe.
I understand how to implement the "on hover" part, by I need help with CSS and overlaying the icons on top of the image/video.
Hello fellow stackers.
I've got a slight problem. I'm trying to duplicated my webpage for another page, however whenever I try and remove the logo the video disappears. Not to sure why. I've input the code however I don't think its much use because it works find by itself, which leads me to believe that there is something within my code which relies on the logo being there. Your help is much obliged. The live example is here. If you inspect element on any browser and remove the logo you'll find that it disappears.
.Intro-Video {
position: relative;
z-index: 9999;
width: 100%;
display: block;
background-color: #fff;
overflow: hidden;
}
.Intro-Video1 {
position: relative;
z-index: 9999;
width: 100%;
display: block;
margin-top: 200px;
background-color: #fff;
overflow: hidden;
}
.video-box {
height: 100%;
width: 100%;
position: relative;
}
#video-container {
height:100%;
width:100%;
overflow: hidden;
}
video {
position:absolute;
z-index:0;
}
video.fillWidth {
width: 100%;
}
.Kadeem-Logo {
position: relative;
top: 0px;
width: 100%;
display:block;
}
.Kadeem-Logo img {
display: block;
width: auto;
max-width: 100%;
}
<div class="video-box">
<div id="video-container">
<video autoplay class="fillWidth">
<source src="http://client.hugoandmarie.com.s35719.gridserver.com/client/AlexandraPosen/Alex_Posen_Video.mp4" type="video/mp4" />
</video>
<div class="Kadeem-Logo">
<img src="http://www.kadeem.london/Content/Image/KL.png" alt="Kadeem Logo" title="Kadeem Logo">
</div>
</div>
</div>
</div>
Your logo image is providing all the height for the container.
Try this:
#video-container {
height: 550px; /* Or whatever height you want */
}
To fix the issue.
I'm trying to create a div that, when you scale your window, trims the picture. This works, but the image is only trimed on the right, not on the left.
How can I also trim it on the left, so that the picture stays in the middle?
My HTML:
<div class="top-foto">
<img src="http://whatatimeline.com/covers/1330597507de0/balloons-sunset-view-facebook-cover.jpg" alt="Coverphoto">
</div>
And my css:
.top-foto {
position: absolute;
z-index: -1;
width: 100%;
height: 315px;
overflow: hidden;
}
.top-foto > img {
margin: 0 auto;
display: block;
max-width: inherit;
}
http://jsfiddle.net/Rings/quz6a3qq/1/
Position the image absolutely as well and center it using translate
* {
margin: 0;
padding: 0;
}
.top-foto {
position: absolute;
z-index: -1;
width: 100%;
height: 315px;
overflow: hidden;
}
.top-foto > img {
position: absolute;
left: 50%;
transform: translateX(-50%);
display: block;
}
<div class="top-foto">
<img src="http://whatatimeline.com/covers/1330597507de0/balloons-sunset-view-facebook-cover.jpg" alt="Cover photo" />
</div>
I got a weird behaviour on IE8 for this
HTML:
<a class='main'>
<img src='http://annawrites.com/blog/wp-content/uploads/2011/04/color-explosion.jpg' />
<div class='layer'> </div>
</a>
CSS:
.main { display: block; position: relative; width: 100px; height: 100px; }
.main img { width: 100px; height: 100px; /*display: none;*/ }
.layer { position: absolute; top: 0px; left: 0px; width: 100%; height: 50%; cursor: crosshair; }
JSFiddle: http://jsfiddle.net/HLua8/2/ (or open this in IE8)
On IE8, .layer (ie. the crosshair cursor) is only on the top left corner (it minimizes itself to the content, which is 3 x )
I noticed it works fine when I set .main img to display:none but I need the image
Could someone help me to make .layer shown on IE8 as big as it is supposed to be? (ie. 100% width 50% height, just like on other browsers)
After much fiddling, the best solution I could come up with for you, is to create a blank/transparent image and use this as the background image for your layer.
add to your css:
.layer {background-image:url(blank.png);}
.layer:hover{cursor: crosshair;}
an updated version of your document would look as follows:
css:
#container {
margin:40px;
position: relative;
width: 100px;
height: 100px;
}
.main img {
max-width: 100%;
}
.layer {
position: absolute;
top: 0px;left: 0px;
width: 100%;height: 50%;
background-image:url(img/blank.png);
}
.layer:hover{cursor:crosshair;}
html:
<div id="container">
<a class='main' href="test.html"><img src='http://annawrites.com/blog/wp-content/uploads/2011/04/color-explosion.jpg' /></a>
<div class='layer'></div>
</div>