I have to Vimeo videos, and I am trying to make them sit side by side and centered in the body whenever a computer is viewing them. Then whenever a small screen (like an iPhone) is viewing them, I want the right one to drop beneath the left one and fit the size of the body.
Here is what I have so far. HTML:
<div class="vimeo-wrapper">
<div class="vimeo-video-1 vimeo-standard">
<iframe src="//player.vimeo.com/video/" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen align="middle" seamless></iframe>
</div>
<div class="vimeo-video-2 vimeo-standard">
<iframe src="//player.vimeo.com/video/" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen align="middle" seamless></iframe>
</div>
</div>
CSS:
.vimeo-standard {
width:500px;
height:auto;
position:relative;
margin: 10px auto;
float: left;
}
.vimeo-video-2 {
margin-left: 15px;
}
.vimeo-wrapper {
width: 100%;
position: relative;
margin: 0 auto;
}
@media (max-width:767px) {
.vimeo-standard {
position: relative;
padding-bottom: 56.25%; /* 16/9 ratio */
padding-top: 30px; /* IE6 workaround*/
height: 0;
overflow: hidden;
}
.vimeo-video-2 {
margin-left: 0;
}
.vimeo-standard iframe, .vimeo-standard object, .vimeo-standard embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
@media (min-width:768px) and (max-width:1199px) {
.vimeo-standard iframe {
width: 352px;
height: 198px;
}
.vimeo-standard {
width: 352px;
}
.vimeo-video-2 {
margin-left: 10px;
}
}
I have created some responsive CSS for it, but I am having trouble getting to just right so that it is centered, responsive, and side-by-side when it is fullscreen.
What should I change the HTML and CSS to for it to do this?
I have edited your css
, it is less now and fully responsive. I have added some extra borders
so you can identify the boundaries of each div you have inside your markup, you may remove them.
the key to center items inside a container is to give position:relative
and margin:0 auto
And yeah, whenever you need to use floating objects inside a container you need to use clearfix
so that container may reset its height
property
.vimeo-wrapper {
max-width: 980px;
position: relative;
margin: 0 auto;
border: 1px solid green;
}
.vimeo-standard {
float: left;
height: 300px;
width: 47%;
border: 1px solid #000;
margin: 10px;
}
iframe {
width: 100%;
height: 100%;
}
@media (max-width:767px) {
.vimeo-standard {
float: none;
width: 80%;
margin: 0 auto;
padding-bottom: 10px;
}
}
.clearfix:before,
.clearfix:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.clearfix:after {
clear: both;
}