i have set up a gallery on my website which displays a large embedded video with 3 thumbnail embedded videos underneath which looks great on the desktop but as i switch to the phone view the 3 thumbnail videos stay in line and dont drop underneath each other as i imagined. Meaning you have to scroll away from the phone screen to view. could someone please advise as to what i need to do? below is the html and css code.
.vid-container {
position: relative;
padding-bottom: 52%;
padding-top: 30px;
height: 0;
}
.vid-container iframe,
.vid-container object,
.vid-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.vid-list-container {
width: 92%;
overflow: hidden;
margin-top: 20px;
margin-left:4%;
padding-bottom: 20px;
}
.vid-list {
width: 1344px;
position: relative;
top:0;
left: 0;
}
.vid-item {
display: block;
position: relative;
width: 18%;
height: 18%;
float: left;
margin: 0;
padding: 10px;
}
.thumb {
overflow:hidden;
height: 84%;
}
.thumb img {
width: 100%;
position: relative;
top: -13px;
}
.vid-item .desc {
color: #21A1D2;
font-size: 15px;
margin-top:5px;
}
<div class="container">
<div class="row">
<div class="m-3 col-xs-7 col-sm-6 col-lg-8">
<h3>This week we are watching....</h3>
<div class="embed-responsive embed-responsive-16by9">
<iframe id="vid_frame" src="https://www.youtube.com/embed/RfuNhK_o9no" frameborder="0"></iframe>
</div>
<div class ="vid-list">
<div class="vid-item" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/HBmDFJRwzQ8'">
<div class="thumb">
<img src="http://img.youtube.com/vi/HBmDFJRwzQ8/0.jpg" alt="" />
</div>
<div class="desc">
Living a healthy lifestyle doesn’t always come easy! But with this one pot meal it doesnt get much easier
</div>
</div>
<div class="vid-item" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/U0jggZfufGU'">
<div class="thumb">
<img src="http://img.youtube.com/vi/U0jggZfufGU/0.jpg" alt="" />
</div>
<div class="desc">
Hey everyone welcome back! Today I have some easy and delicious summer treats! These are easy and inexpensive treats and taste amazing! I hope you enjoyed!
</div>
</div>
<div class="vid-item" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/p4b2rFW8cms'">
<div class="thumb">
<img src="http://img.youtube.com/vi/p4b2rFW8cms/0.jpg" alt="" />
</div>
<div class="desc">
From the archives: Once again Gennaro invites us into his home to show us another wholesome home cooked meal.
</div>
</div>
</div>
</div>
</div>
</div>
make sure that if you added view port meta <meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=2, minimum-scale=0.5, width=device-width, height=device-height, target-densitydpi=device-dpi" />
like above, also your media query does not respond without viewport for responsive
Guess you want to achieve this?
If you are already using bootstrap why not use another nested row for the videos below the 'main'-video?
I replaced the .vid-list class with a .row bootstrap class and assumed that you want to have three other videos below the main video. Since bootstrap is using 12 columns i divided 12 by 3 and got 4. So i used .col-md-4 to use 4 columns for one video. On small devices you want to use the full length so you are using .col-sm-12.
And try to avoid using negative top and margin values. I also cleared up some (not everything) of unnecessary code.
.vid-container {
position: relative;
padding-bottom: 52%;
padding-top: 30px;
height: 0;
}
.vid-container iframe,
.vid-container object,
.vid-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.vid-list-container {
width: 92%;
overflow: hidden;
margin-top: 20px;
margin-left:4%;
padding-bottom: 20px;
}
.vid-list {
margin-top: 10px;
}
.thumb {
overflow:hidden;
height: 84%;
}
.thumb img {
width: 100%;
position: relative;
top: -13px;
}
.vid-item .desc {
color: #21A1D2;
font-size: 15px;
margin-top:5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="m-3 col-xs-7 col-sm-6 col-lg-8">
<h3>This week we are watching....</h3>
<div class="embed-responsive embed-responsive-16by9">
<iframe id="vid_frame" src="https://www.youtube.com/embed/RfuNhK_o9no" frameborder="0"></iframe>
</div>
<div class ="row vid-list">
<div class="vid-item col-sm-12 col-md-4" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/HBmDFJRwzQ8'">
<div class="thumb">
<img src="http://img.youtube.com/vi/HBmDFJRwzQ8/0.jpg" alt="" />
</div>
<div class="desc">
Living a healthy lifestyle doesn’t always come easy! But with this one pot meal it doesnt get much easier
</div>
</div>
<div class="vid-item col-sm-12 col-md-4" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/U0jggZfufGU'">
<div class="thumb">
<img src="http://img.youtube.com/vi/U0jggZfufGU/0.jpg" alt="" />
</div>
<div class="desc">
Hey everyone welcome back! Today I have some easy and delicious summer treats! These are easy and inexpensive treats and taste amazing! I hope you enjoyed!
</div>
</div>
<div class="vid-item col-sm-12 col-md-4" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/p4b2rFW8cms'">
<div class="thumb">
<img src="http://img.youtube.com/vi/p4b2rFW8cms/0.jpg" alt="" />
</div>
<div class="desc">
From the archives: Once again Gennaro invites us into his home to show us another wholesome home cooked meal.
</div>
</div>
</div>
</div>
</div>
</div>
Related
Everything seems to be positioned where I want it but the image and video will overlap the jumbotron on the smaller size. I have checked other posts and have not found anything useful to answer my question. I should clarify that it comes out at the right side of the jumbotron.
<style>
body {
margin: 20px;
}
#img_position {
position: relative;
left: 14%;
padding: 15px;
max-width: 100%;
}
#jumbo
{
background-color: #bfff80;
font-family: 'Cinzel', serif;
min-width: 100%;
}
.gw_vid{
position:relative;
padding-top:5%;
max-width:32%;
margin:0 auto;
}
</style>
<div class="container box ">
<div id="jumbo" class="jumbotron box">
<h1 style="text-align: center">George Washington</h1>
<h4 style="text-align:center">The first President of the Untited States of America</h4>
<img id="img_position" src="http://projectmanagementhacks.com/wp-content/uploads/2015/03/George-Washington-Success-Principles.jpg">
<div class="gw_vid">
<iframe width="350px" height="350px" src="https://www.youtube.com/embed/thin1LeCrxY" target="blank"></iframe>
</iframe>
</div>
</div>
I added col-md-12 to my picture and that resolved that issue for now but I tried the col-md-12 with the video and got no good results.
Any help with the video issue would be great.
I put your code into Codepen and It told me i don't need tags, first of all after i took out the style tags i ran the code and it looks perfectly fine. I beleive solution here is to create a new file for the CSS then link them in the head. If you don't know how to do that, here is the code
<link rel="stylesheet" type="text/css" href="nameoffyourfile.css"
**HTML**
<div class="container box ">
<div id="jumbo" class="jumbotron box">
<h1 style="text-align: center">George Washington</h1>
<h4 style="text-align:center">The first President of the Untited States of
America</h4>
<img id="img_position" src="http://projectmanagementhacks.com/wp-
content/uploads/2015/03/George-Washington-Success-Principles.jpg">
<div class="gw_vid">
<iframe width="350px" height="350px"
src="https://www.youtube.com/embed/thin1LeCrxY" target="blank"></iframe>
</iframe>
</div>
</div>
**CSS**
body {
margin: 20px;
}
#img_position {
position: relative;
left: 14%;
padding: 15px;
max-width: 100%;
}
#jumbo {
background-color: #bfff80;
font-family: 'Cinzel', serif;
min-width: 100%;
}
.gw_vid {
position: relative;
padding-top: 5%;
max-width: 32%;
margin: 0 auto;
}
Since you are using Bootstrap, you can use the native responsive embed for your YouTube video: http://getbootstrap.com/components/#responsive-embed
I am trying to achieve facebook alike image cover as follow, but unable to achieve desire effect. This is the css that i have try. As you all can see, the div content does not position correctly.
.profile {
position: relative;
}
.profile-cover img{
width: 100%;
}
.profile-photo {
position: absolute;
left: 20px;
bottom: -60px;
}
.profile-info {
padding-right: 120px;
}
<div class="profile">
<div class="profile-cover">
<img src="http://dummyimage.com/1200x300/000/fff" />
</div>
<div class="profile-details">
<div class="profile-photo">
<img src="http://dummyimage.com/100x100/eee/000" />
</div>
<div class="profile-info">
Profile info here
</div>
</div>
</div>
<div>
Remaining content here
</div>
I am not exactly sure if you wanted this because you just say the "the div content does not position correctly", but I'm quiet sure it's that.
So, if not, tell me.
Using the absolute positioning gets out of the flow the element. So, the next ones continues as if this element didn't exist. That's why the others were showing under this absolute element.
For next time, please precise which DIV by using its id, a class name or anything that we can know for sure the one you are talking about.
.profile {
position: relative;
}
.profile-cover img{
width: 100%;
}
.profile-photo {
display: inline-block;
margin-top: -60px;
margin-left: 20px;
}
.profile-info {
display: inline-block;
padding-right: 120px;
}
<div class="profile">
<div class="profile-cover">
<img src="http://dummyimage.com/1200x300/000/fff" />
</div>
<div class="profile-details">
<div class="profile-photo">
<img src="http://dummyimage.com/100x100/eee/000" />
</div>
<div class="profile-info">
Profile info here
</div>
</div>
</div>
<div>
Remaining content here
</div>
This is how I would do it ...
.profile {
margin-bottom: 15px;
}
.profile-cover img {
width: 100%;
}
.profile-photo {
display: inline-block;
margin-left: 20px;
margin-top: -24px;
}
.profile-info {
display: inline-block;
position: relative;
top: -25px;
left: 10px;
}
<div class="profile">
<div class="profile-cover">
<img src="http://dummyimage.com/1200x300/000/fff" />
</div>
<div class="profile-details">
<div class="profile-photo">
<img src="http://dummyimage.com/100x100/eee/000" />
</div>
<div class="profile-info">
Profile info here<br>
More info here
</div>
</div>
</div>
<div>
Remaining content here
</div>
This works for bigger screen and shows the way I want but on Mobile, "Right Title" overlaps the "Left Title". Left title should go up but Right Title should be below it but instead, it goes on top of the Left Title.
What should I do?
<div class="IdeathonCover">
<img class="img-responsive" width="100%" src="bg-image.jpg">
<div class="IdeathonLeftTitle">
<h1>Left Title</h1>
</div>
<div class="IdeathonRightTitle">
<h1>Right Title</h1>
</div>
</div>
I tried this method too using the bootstrap 3 layout but it didn't work. The "col-x-12" is not being respected:
<div class="IdeathonCover">
<img class="img-responsive" width="100%" src="bgimage.jpg">
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="IdeathonLeftTitle">
<h1>Left Title</h1>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="IdeathonRightTitle">
<h1>Right Title</h1>
</div>
</div>
</div>
</div>
The CSS used is below:
.IdeathonCover {
position: relative;
}
.IdeathonLeftTitle {
position:absolute;
bottom: 10%;
left: 0;
padding: 0px 50px 20px;
color: #fff;
font-weight: 300;
}
.IdeathonRightTitle {
position:absolute;
bottom: 10%;
right: 0;
padding: 0px 50px 20px;
color: #fff;
font-weight: 300;
}
Anyone knows why this is happening?!
If you are using Bootstrap, as far as I'm aware, there is nothing wrong with using Bootstrap classes within absolute positioned elements. You could try something along the lines of:
CSS:
.IdeathonCover {
position: relative;
}
.IdeathonTitles {
position: absolute;
bottom: 10%;
width: 100%;
}
And your html:
<div class="container-fluid">
<div class="row">
<div class="IdeathonCover">
<img class="img-responsive" src="bgimage.jpg" alt="">
<div class="IdeathonTitles">
<div class="col-md-6">
<h1 class="text-center">Left title</h1>
</div>
<div class="col-md-6">
<h1 class="text-center">Right title</h1>
</div>
</div>
</div>
</div>
</div>
try adding this in the end of your css file-
#media (min-width: 320px) and (max-width: 750px){
.IdeathonLeftTitle { right: 0; }
.IdeathonRightTitle { left: 0; top: 67px; }
}
it should help.
I am making a site and using bootstrap 3.3.5. The only problem I am having at the moment is the row/column structure I have is not displaying correctly on mobile.
Here is the link to the project: https://foreverfightermovie.herokuapp.com/#/home
It looks fine so far on a computer browser, but on mobile the ribbons are stacked onto of the middle panel section. Here is the html I am using:
<div class="jumbotron">
<h3 class="text-right" style="margin-right: 100px"> Production status: <b>Pre-Production</b> </h3>
<h1 class="text-center">The official site of <h1>
<div class="container">
<div class="row">
<div class="col-md-3">
<img src="/images/breast-cancer-ribbon.png" width="200" height="400" style="margin-left: 30px"/>
</div>
<div class="col-md-6">
<div class="panel-body text-center px-font" style="background-color: pink">
<br><b><FONT FACE="Lucida Console">FOREVER<br>FIGHTER</FONT></b><br><br>
<h3><i>"In life you can fight forever, but you can't live forever. One is a choice and the other is a guarantee"</i><h3>
</div>
</div>
<div class="col-md-3">
<img src="/images/breast-cancer-ribbon.png" width="200" height="400"/>
</div>
</div>
</div>
<br>
<p class="text-center"><a class="btn btn-primary btn-lg text-center" style="color: #2BDE73">
<img src="/images/kickstarter-logo.png" width="30" height="30"/>
Click for Donation Pledges</a></p>
</div>
Also: Here is the css I am using:
.tab { margin-left: 20px;
margin-right: 20px; }
.imagetab { margin-left: 40px;
margin-right: 40px;}
.para {
text-indent: 40px;
}
.jumbotron {
margin-left: 30px;
margin-right: 30px;
}
html {font-size: 90%;}
div.px-font {
font-size: 110px;
}
Does anyone have any suggestions on how to fix it?
Bootstrap's strength is stacking, but you can override whatever you'd like in your custom CSS. For what you'd like to do I'd use a media query with Bootstrap's built-in breakpoints. Here's a simple example:
#media (max-width: #screen-sm-min) {
/* This is the row containing your main panel and two ribbon divs. */
.main-row {
position: relative;
}
/* Add this to each of your ribbons. The ".left" & ".right" are self-explanatory. */
.ribbon {
position: absolute;
top: 100px;
}
.ribbon.left { left: 0px; }
.ribbon.right { right: 0px; }
/* Resize your images here to fit as you'd like them. */
.ribbon img {
height: 100px;
width: 50px;
}
}
You can find some more info on the queries Bootstrap offers here: http://getbootstrap.com/css/#grid-media-queries
I would like to put one image above another, but all answers I find are using position absolute with specific pixels. I want to achieve it in a responsiveness way, so I would like to avoid strict composition.
Now my code looks like:
<style>
.header{
margin:20px;
text-align:center;
}
.data{
text-align:center;
}
</style>
<body>
<h1>Hello Stack Overflow!</h1>
<div class="header">
<img src="http://lorempixel.com/g/800/200/" class="background">
<img src="http://lorempixel.com/100/100/" class="logo">
</div>
<div class="data">
<label>enter your name</label>
<input>
</div>
I would like to move the .logo img above the background img and, have different classes to move it:
Center center;
Center right;
Center left;
So, my goal is having the possibility to accomplish the following image with a class that can "move" my logo, but always maintaining it above the background image. Note that the background image could have not always the same size.
I did a plunkr to test with where you can reproduce it.
Although this answer uses absolute positioning it is responsive and should work they way you want. This answer also assumes that you have high quality background images that will not lose quality when scaled to a large size.
The logo is centered by default. There is a .logo-right and .logo-left class for side positioning.
There is a small edge case that the logo breaks out a little at small screens when the height of the background image is less than the logo. To account for this you can set the logo width to a percentage and also give it a max-width so that it doesn't enlarge too far if you are using a rasterized (non-svg) logo (see Snippet) .
.header {
margin:20px;
text-align:center;
position: relative;
}
.data{
text-align:center;
}
.background {
height: auto;
width: 100%;
}
.logo {
bottom: 0;
height: 50%;
left: 0;
margin: auto;
max-height: 100px;
position: absolute;
right: 0;
top: 0;
width: auto;
}
.logo-right {
margin-right: 5%;
}
.logo-left {
margin-left: 5%;
}
<h1>Centered</h1>
<div class="header">
<img src="http://lorempixel.com/g/800/200/" class="background">
<img src="http://lorempixel.com/100/100/" class="logo">
</div>
<div class="data">
<label>enter your name</label>
<input>
</div>
<h1>Right</h1>
<div class="header">
<img src="http://lorempixel.com/g/800/200/" class="background">
<img src="http://lorempixel.com/100/100/" class="logo logo-right">
</div>
<div class="data">
<label>enter your name</label>
<input>
</div>
<h1>Left</h1>
<div class="header">
<img src="http://lorempixel.com/g/800/200/" class="background">
<img src="http://lorempixel.com/100/100/" class="logo logo-left">
</div>
<div class="data">
<label>enter your name</label>
<input>
</div>
Maybe something like this?
http://plnkr.co/edit/wd6wui?p=preview
<style>
.header {
margin: 20px;
text-align: center;
position: relative;
}
.img-container {
position: absolute;
top: 0;
width: 100%;
}
.data {
text-align: center;
}
img {
max-width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
<div class="header">
<div class="img-container">
<img src="http://lorempixel.com/g/800/200/" class="background">
</div>
<div class="img-container">
<img src="http://lorempixel.com/100/100/" class="logo">
</div>
</div>
Not sure I understood your question ;)
wrapping the images in div will do the work
<div><img src="http://lorempixel.com/100/100/" class="logo"></div>