Using rows and column from bootstrap for mobile - html

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

Related

Center align absolute positioned icon in 767px screen

The absolutely positioned icons in the two columns need stay center aligned across all resolutions. Below is the media query I tried to align the icon in mobile device. It is not accurate in any of the resolutions. How can I correct the CSS?
#media screen and (max-width: 767px) {
.contact-mode-icon {
top: -4rem;
}
.contact-mode-col {
margin-bottom: 6rem !important;
}
}
HTML:
<div class="row connect-with-concierge-row">
<div class="col contact-mode-col col-xs-12 col-md-4">
<div class="contact-mode-icon">
<img src="http://pwp-wordpress/wp-content/uploads/2022/09/emailicon-png.png">
</div>
<div class="contact-mode-content">
<div class="icon-title">SUBMIT QUESTIONS</div>
<div class="icon-description" style="height: 106px;"><span>Fill out this form </span> with your questions or requests and we'll respond ASAP (maximum one business day)</div>
<div class="center-xs connect-with-concierge-cta">
<a id="btn" class="btn" role="button" target="" title="Complete Form">
Complete Form </a>
</div>
</div>
</div>
<div class="col contact-mode-col col-xs-12 col-md-4">
<div class="contact-mode-icon">
<img src="http://pwp-wordpress/wp-content/uploads/2022/09/Call_Icon_png.png" ;="">
</div>
<div class="contact-mode-content">
<div class="icon-title">TALK TO AN EXPERT</div>
<div class="icon-description" style="height: 106px;"><span>Prefer to schedule a call? </span> Meet live with a member of our Gift Concierge team at a time most convenient for you</div>
<div class="center-xs connect-with-concierge-cta">
<a href="#" class="btn cta-btn-purple" role="button" target="" title="Schedule a Meeting">
Schedule a Meeting </a>
</div>
</div>
</div>
</div>
CSS:
.contact-mode-icon {
position: absolute;
top: -3rem;
left: 9rem;
}
.contact-mode-content {
border: 2px solid;
border-color: #A6A2A3;
padding-top: 3rem;
padding-bottom: 1rem;
max-width: 342px;
}
.contact-mode-content .icon-title {
font-family: 'Roboto';
font-weight: bold;
text-transform: capitalize;
font-size: 1.2rem;
margin: 1rem auto;
}
.contact-mode-content .icon-description {
font-family: 'Roboto';
font-size: 1rem;
padding: 0 1.1rem;
margin-bottom: 1rem;
}
.contact-mode-content .icon-description span {
font-weight: bold;
}
.contact-mode-content .btn {
padding: 1rem;
}
.connect-with-concierge {
margin-top: 3rem;
}
The image below shows misaligned icon.
Here is the page
Your icon isn't centered properly in normal resolution - check inspector tool and see that content of the column is left aligned since you set its max width but the div remains the same size.
Now to your question: you can easily fix that with transform: translate property like this:
.contact-mode-icon {
position: absolute;
top: 0;
left: 50%;
transform: translate(-50%, -50%);
}
.contact-mode-content {
#your code that you have already
margin: 0 auto;
}
You will also need to delete that media query fix for content-mode-icon.

Video stays inline on mobile

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>

My image and my iframe video fall outside of my jumbotron when I resize them to the smaller size. How do I prevent this?

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

Boostrap: How to "stick" a button over an image when re-sizing

I have an image in which I need to put a button over, the problem is that I don't know how to place the button and automatically re-size and position it when making the browser smaller, right now I have the button in place, but when I re-size the browser to get smaller the button moves, I tried using percentages in the css buy doesn't work, what can I do?
<div id="discover" class="container-fluid">
<div class="row-fluid">
<div class="col-lg-12 col-sm-12 col-xs-12 col-md-12 withimg">
<img id="discoveryour" src="img/x.png" class="img-responsive">
</div>
</div>
<div class="row-fluid">
<div id="bttnimg" class="col-lg-12 col-sm-12 col-xs-12 col-md-12">
<form id="start" method="post" action="x.php">
<button class="btn-primary">text</button>
</form>
</div>
</div>
</div>
Css:
.withimg {
width: 100%;
overflow:hidden;
padding: 0px;
margin: 0px;
}
#discover{
position: relative;
}
#bttnimg{
float: left;
position: absolute;
left: 62%;
top: 25%;
max-width: 750px;
}
Ah, the good old "how to overlay stuff on top of a responsive image -- responsively" question.
A little tricky, but not too bad. The tricky bit is how to make the stuff's vertical position responsive when the image size changes.
Fear not, here's one simple way to do this:
HTML:
<div class="img-wrapper">
<img class="img-responsive"
src="http://lorempixel.com/output/people-q-c-1200-400-4.jpg">
<div class="img-overlay">
<button class="btn btn-md btn-success">Button</button>
</div>
</div>
CSS:
.img-wrapper {
position: relative;
}
.img-responsive {
width: 100%;
height: auto;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
}
.img-overlay:before {
content: ' ';
display: block;
/* adjust 'height' to position overlay content vertically */
height: 50%;
}
The img-overlay:before pseudo-class handles the vertical positioning job by pushing the img-overlay div down from the top of the image. In this example, the top of the button will always be 50% down the image (change the height: 50% attribute if you want the button higher or lower).
jsfiddle
To make the button size responsive to window width, you can create a new class for your button. Let's call it btn-responsive (this replaces btn-md in the example above). Then use #media queries to adjust the btn-responsive attributes for different window widths. Something like this:
.btn-responsive {
/* matches 'btn-md' */
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
border-radius: 6px;
}
#media (max-width:760px) {
/* matches 'btn-xs' */
.btn-responsive {
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
}
and so forth for other screen widths.
In case you're wondering how to do this with bootstrap 5 (like me), there are new classes that do the trick. For instance, I did this to put a button floating right top over the image (I also use font-awesome but you can use any text/icon you like for the button):
<div class="card">
<img class="card-img-top img-thumbnail" src="someimage.png" alt="alt text">
<div class="card-img-overlay">
<a href="#" class="btn btn-outline-warning btn-sm float-end"
data-bs-toggle="popover" data-bs-content="Edit image" data-bs-trigger="hover focus">
<i class="far fa-edit"></i>
</a>
</div>
<div class="card-body">
<h5 class="card-title">Some title</h5>
<p class="card-text">Some text</p>
</div>
</div>
Check out the official bootstrap documentation for more info.
I have to ask if there's a possibility to replace form tag into another DIV? Then you can just use position: absolute for button. I created fiddle to show how https://jsfiddle.net/1x1pjwk7/

Trouble resizing bootstrap 3 box to fit with image

Please see the first image below.
This is working great and is how I want it to look. However when the browser resizes it then looks like this.
As you can see the white background of the text block is bigger than of the image block. I want the image block to be the same height as the text block but unfortunately this is not working. I am using Bootstrap 3 to develop this and you can see my code for this below:
<div class="row" style="margin-bottom:30px;">
<div class="col-xs-12">
<div class="col-sm-3" style="padding:0;">
<img src="core/img/abb[square].jpg" class="img-responsive">
</div>
<div class="col-sm-9" style="background:#fff; height:218px; padding:7px 25px;">
<h2><a class="a-cl">Page title</a> <small>2.1 miles away</small></h2>
<p>Text content, summary of page here.</p>
Subscribed <i class="glyphicon glyphicon-ok" style="margin-left:4px;"></i>
</div>
</div>
</div>
Any help would be much appreciated. As you can see I have manually defined the height on <div class="col-sm-9"> and set height:218px. This obviously will not work dynamically as the page resizes.
Summary: I am looking for an effective way of making sure the height of the text block is the same as the image block using bootstrap 3.
Okay, this is with intrinsic ratios, it's not like the comments I made. However, the comment about the rows and columns and nesting are correct.
DEMO: http://jsbin.com/zodama/1/
http://jsbin.com/zodama/1/edit
Requires: jquery.matchHeight-min.js
https://github.com/liabru/jquery-match-height
jQuery (when the script is installed):
$(document).ready(function() {
$('.my-row [class*="col-"]').matchHeight();
});
The CSS, some of which is the aspect ratio and some of which is Bootstrap grid manipulation based on intimate knowledge of how it works.
.my-row {
border: 10px solid #ddd;
margin-left: 0;
margin-right: 0;
margin-bottom: 3%;
text-align: center;
}
.image img {
display: block;
max-width: 100%;
height: auto;
margin: 0 auto;
}
.my-row [class*="col-"] {
padding:0 0 10px 0;
}
#media (min-width:768px) {
.my-row {
border: 10px solid #ddd; /* remove this it's in the global */
text-align: left;
}
.my-row [class*="col-"] {
padding: 0;
min-height: 220px;
}
.my-row [class*="col-"]:last-child {
padding-left: 20px;
padding-bottom: 20px;
}
.image img {
display: block;
width: 100%;
height: 100%;
margin: auto;
-webkit-transition: all 2s ease-out;
transition: all 2s ease-out;
}
.image img {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.image {
position: relative;
height: 0;
padding-top: 56.25%;
}
}
#media (min-width:992px) {
.my-row [class*="col-"] {
min-height: 250px;
}
}
#media (min-width:1200px) {
.my-row [class*="col-"] {
min-height: 275px;
}
}
HTML
<div class="container">
<div class="row my-row">
<div class="col-sm-4 col-md-3 image">
<img src="http://lorempixel.com/320/320/sports"/>
</div>
<div class="col-sm-8 col-md-9">
<h2><a class="a-cl">Page title</a> <small>2.1 miles away</small></h2>
<p>Text content, summary of page here.</p>
Subscribed <i class="glyphicon glyphicon-ok"></i>
</div>
</div>
<div class="row my-row">
<div class="col-sm-4 col-md-3 image">
<img src="http://lorempixel.com/320/320/city"/>
</div>
<div class="col-sm-8 col-md-9">
<h2><a class="a-cl">Page title</a> <small>2.1 miles away</small></h2>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
Subscribed <i class="glyphicon glyphicon-ok"></i>
</div>
</div>