Bootstrap thumbnail images ignore centering css - html

I cannot center my bootstrap thumbnail images no matter what I try on tablet size and smaller. Once thumbnails reach thoses sizes they no longer scroll to stay center of screen. I have tried everything I can think of from adding center block to both my thumbnail class's and my img responsive class's HTML to text-algin center and margin auto 0. Nothing changes.
Here is my html
<div class="portfolio">
<div class="container">
<a name="porty"></a>
<h1 class="text-center" id = "port">My Work</h1>
<div class="row">
<div class="col-md-4">
<div class="thumbnail ">
<div class="caption">
<h4 class="text-center">A Berine Sanders Tribute page made with HTML,CSS, and Bootstrap</h4> <i class="fa fa-codepen fa-5x fa-fw" id="first"></i>
</div>
<img src="http://goodedevelopment.com/images/Bernie.PNG" class="img-responsive center-block" alt="tribute">
</div>
<legend>Tribute page</legend>
</div>
<div class="col-md-4">
<div class="thumbnail">
<div class="caption">
<h4 class="text-center">Google mockup page made with HTML,CSS,and Bootstrap</h4>
<i class="fa fa-codepen fa-5x fa-fw" id ="second"></i>
</div>
<img src="http://goodedevelopment.com/images/google.png" class="img-resposive center-block" alt="google">
</div>
<legend>Google homepage</legend>
</div>
<div class="col-md-4">
<div class="thumbnail">
<div class="caption">
<h4 class="text-center">A cannon game made with HTML,CSS, and Javascript</h4>
<i class="fa fa-codepen fa-5x fa-fw" id ="icon"></i>
</div>
<img src="http://goodedevelopment.com/images/cannon.png" class="img-responsive center-block" alt="cannon">
</div>
<legend>Cannon game</legend>
</div>
</div>
Here is my CSS
/*Portfolio*/
.portfolio {
background-color:#706C61;
padding-top: 50px;
padding-bottom: 100px;
display: inline-block;
width: 100%;
height: 800px;
position:relative;
}
.portfolio h1 {
font-size: 65px;
font-family: "Roboto",serif !important;
color: #0d0d0d !important;
}
.row {
padding-top: 100px;
}
.thumbnail {
height: 250px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
border: 1px solid black !important;
border-radius: 5px !important;
}
.caption img {
flex-shrink: 0;
max-width 100%;
max-height: 100%;
}
.caption {
position: absolute;
top: 0;
right: 0;
background: rgba(128, 128, 128, 0.75);
width: 100%;
height: 100%;
padding: 2%;
display: none;
text-align: center;
color: #fff !important;
z-index: 2;
font-family: "Montserrat",serif !important;
}
.caption a {
text-decoration: none;
color: white;
}
.caption h4 {
position: relative;
left: 5px;
bottom: 10px;
font-size: 25px;
}
.caption i:hover {
color: orange !important;
}
legend {
font-family: "Roboto",serif !important;
border-bottom: none !important;
color: #0d0d0d !important;
font-size:22px; !important;
height:200px;
}
#first {
position: relative !important;
bottom: -35px !important;
}
#second {
position: relative !important;
bottom: -35px !important;
}
#icon {
position: relative;
top: 30px;
}
#media screen and (min-width:767px) and (max-width:1199px) {
#first {
position: relative;
bottom: 20px;
}
#icon {
top: 50px !important;
}
.caption h4 {
font-size: 20px;
}
}
#media screen and (min-width:767px) and (max-width:991px) {
#first {
position: relative;
top: 50px;
}
.caption h4 {
font-size: 30px;
}
.caption {
font-size: 15px;
}
.caption i {
position: relative;
top: 50px;
}
#icon {
position: relative;
top: 65px !important;
}
.caption .fa {
font-size: 50px;
}
}
#media screen and (max-width: 1200px) {
.portfolio h1 {
font-size: 55px;
}
}
#media screen and (max-width: 991px){
.thumbnail {
height: 369px;
width: 440px;
position: relative;
right: -142px;
bottom: 48px;
}
.portfolio{
height: 2650px;
}
#profile li {
position: relative;
left: 60px;
}
.caption h4 {
font-size: px !important;
}
.caption .fa {
font-size: 80px !important;
}
legend {
height: 80px;
position: relative;
left: 139px;
bottom: 53px;
}
}
#media screen and (max-width: 965px) {
.portfolio {
margin-top: -150px !important;
}
}
#media screen and (max-width:767px) {
#first {
position: relative;
top: 25px;
}
.caption h4 {
font-size: 30px;
}
.caption {
font-size: 15px;
}
#port{
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: -1285px;
left: 0;
bottom: 0;
right: 0;
}
.thumbnail {
position: relative;
bottom: 0px;
}
legend
{
position: relative;
bottom: 13px;
}
}
#media screen and (max-width: 454px){
.caption h4{
font-size:25px;
}
#first{
top:15px;
}
#second{
top:15px;
}
}
#media screen and (max-width:400px) {
#icon {
position: relative;
bottom: 20px;
}
}
#media screen and (max-width:397px) {
#icon {
position: relative;
top: 0px;
}
}
#media screen and (max-width:390px) {
#first{
top:5px;
}
}
#media screen and (max-width:325px) {
.caption .fa {
font-size:60px;
}
}
#media screen and (max-width:307px) {
#first{
top:-5px;
}
}
/*End Portfolio*/
Here is the website
And finally here is a screenshot of what I am experiencing any help would be greatly appreciated thanks!

Instead of just using class="col-md-4" you should include "instructions" for Bootstrap at different screen sizes. Using multiple classes like class="col-xs-12 col-sm-6 col-md-4" would adjust the number of columns at the various screen sizes, making it easy to center the contents of each column, and just use the "img-responsive" class on the images so they will always fit in the column they are in. Then when the screen size is smaller, fewer columns will be displayed but the content of the column remains the same and stays centered in the column. If you want to center the column on the screen without filling the width of the screen (like to use col-xs-10 so it doesn't fill the width of 12 col's) then use the col-x-offset-x class to create a "blank" column to the left of where your div will display. You can use combinations of screen sizes and offsets as needed. The grid makes it really easy to get the alignment you want at different sizes without having to use CSS to define exact pixels for margins and whatnot. Once you start overwriting the CSS with "other instructions" as far as height/width go, things can get goofy...

Your fixed-navbar are with a width bigger than lower resolutions, theres alot of blank space on the right when you drop the resolution. I recommend you start developing your website following this basic bootstrap responsible template.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Bare - Start Bootstrap Template</title>
<!-- Custom CSS -->
<link data-require="bootstrap-css#3.2.0" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<script data-require="jquery#*" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<style>
body {
padding-top: 70px;
/* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
}
</style>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Start Bootstrap</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1>A Bootstrap Starter Template</h1>
<p class="lead">Complete with pre-defined file paths that you won't have to change!!</p>
<ul class="list-unstyled">
<li>Bootstrap v3.3.7</li>
<li>jQuery v1.11.1</li>
</ul>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</body>
</html>
Rebase your website inside the .container and link your style and keep going.. I hope it helps you to understand better the concepts of bootstrap, i cannot do the whole job for you after all you are a full stack developer.

Related

Responsive Design without bootstrap

I'm having a bit of a design issue with a website I'm trying to build in that I can't get it to be responsive to the different screen resolutions.
html,
body {
margin: 0 auto;
font-family: 'Roboto', sans-serif;
}
.menubar {
position: absolute;
z-index: 150;
}
#logo {
width: 550px;
position: absolute;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
top: 40%;
}
.menubar ul,
li,
a {
display: inline-block;
text-decoration: none;
color: white;
padding: 10px;
z-index: 1000;
}
.menubar a:hover {
text-decoration: underline;
}
.menubar.two a {
color: black;
}
.slider-contain {
height: 100vh;
width: 100%;
overflow: hidden;
z-index: -1;
}
.a-slide {
background-size: cover !important;
}
.slick-slider {
height: 100%;
width: 100%;
z-index: -1;
}
.slick-list,
.slick-track {
height: 100%;
}
.overlay {
height: 100%;
width: 100%;
position: absolute;
z-index: 101;
background: rgba(0, 0, 0, 0.6);
}
.overlay p {
color: white;
position: absolute;
font-size: 30px;
width: auto;
top: 85%;
font-family: 'Caveat', cursive;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%)
}
.overlay h2 {
font-size: 30px;
color: white;
width: auto;
top: 90%;
position: absolute;
font-family: 'Caveat', cursive;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%)
}
.brand-wrap {
border-bottom: 1px black solid;
}
.item {
width: 500px;
margin: 30px;
display: inline-block;
}
.slick-slidertwo {
height: 100%;
width: 100%;
}
.overlay-about {
height: 100%;
width: 100%;
position: absolute;
z-index: 101;
background: rgba(0, 0, 0, 0.6);
color: white;
}
.wrap-about {
width: 50%;
padding-top: 175px;
padding-left: 65px;
}
.overlay-about p {
line-height: 27px;
width: 700px;
}
.overlay-about h1 {
color: goldenrod;
}
#about {
text-decoration: none;
line-height: 0;
font-size: 0;
}
.wrap-service {
padding-top: 95px;
padding-left: 100px;
}
.services h1 {
color: goldenrod;
margin-left: -20px;
}
.services p {
line-height: 30px;
margin-left: -20px;
width: 52%
}
#s1 {
width: 600px;
height: 600px;
margin-right: 60px;
display: block;
-webkit-box-shadow: 5px 10px 16px 1px rgba(0, 0, 0, 0.41);
-moz-box-shadow: 5px 10px 16px 1px rgba(0, 0, 0, 0.41);
box-shadow: 5px 10px 16px 1px rgba(0, 0, 0, 0.41);
}
#underline {
width: 50%;
float: left;
margin-top: -20px;
margin-left: -20px;
}
.service-images {
float: right;
margin-top: 50px;
}
.service-items {
width: 63%;
display: inline-block;
margin-left: -43px;
}
.wrap-service h1 {
font-size: 55px;
color: goldenrod;
}
.empty {
height: 100px;
}
.footer {
width: 100%;
height: 50px;
border-top: lightgrey 1px solid;
text-align: center;
}
#googleMap {
width: 80%;
height: 100vh;
float: left;
}
.contact-wrap {
width: 100%;
display: table;
}
.contact {
height: 100vh;
width: 19.8%;
float: right;
border-left: 2px solid black;
}
.menubar.two {}
.contact p {
line-height: 10px;
text-align: center;
font-weight: bold;
}
/* Smartphones (portrait and landscape) ----------- */
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* Smartphones (landscape) ----------- */
#media only screen and (min-width: 321px) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* Smartphones (portrait) ----------- */
#media only screen and (max-width: 320px) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* iPads (portrait and landscape) ----------- */
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* iPads (landscape) ----------- */
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* iPads (portrait) ----------- */
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* Desktops and laptops ----------- */
#media only screen and (min-width: 1224px) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
/* Large screens ----------- */
#media only screen and (min-width: 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
top: 50%;
}
<!Doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>R&R Cycle: Motorcycle and ATV Service Center</title>
<!-- Main CSS + Slick Slider CSS Files -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="slick/slick/slick.css" />
<link rel="stylesheet" type="text/css" href="slick/slick/slick-theme.css" />
<!-- Google Fonts, FontAwesome, Favicon, Crawler JS for brands scroll -->
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Caveat" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon" href="img/favicon-motorcycle.ico" />
<script src="js/crawler.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="fa/css/font-awesome.min.css">
<!-- JQuery -->
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<!-- AOS for scroll animations -->
<script src="aos-master/dist/aos.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="aos-master/dist/aos.css" /> </head>
<body>
<!-- Start Menu -->
<div class="menubar">
<ul class="mainmenu">
<li><a style="color:goldenrod;" href="#home">Home</a></li>
<li>About</li>
<li>Services</li>
<li>Part Catalogs</li>
<li>Contact / Hours</li>
</ul>
</div>
<!-- Splash Page Slider + Overlay info -->
<div class="slider-contain">
<div class="overlay">
<img id="logo" align="right" src="img/R&R.png" alt="">
<p>Service and Repair for All Makes and Models Since 1979!</p>
<h2>Call Us Today: 845-336-5910</h2>
</div>
<div class="slick-slider">
<div class="a-slide" style="background: url('img/slider-4.jpeg') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/slider-2.jpeg') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/slider-3.jpeg') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/slider-5.jpg') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/sunset-summer-motorcycle.jpg') no-repeat center center"></div>
</div>
</div>
<!--Brands slider w/ Crawler JS -->
<br />
<div class="brand-wrap">
<div id="brands"> <img id="banner" src="img/banner.jpg" /> </div>
</div>
<!-- End Brand Slider -->
<!-- About Us Slider + Info -->
<div class="slider-contain">
<div class="overlay-about">
<a id="about"></a>
<div class="wrap-about">
<h1>About "The Shop"</h1>
<p data-aos="fade-up">We are nestled in the scenic Catskill mountains in the Hudson River Valley, home to some of the best riding areas in the northeast. Situated about 2 hrs. north of New York City and just a few miles from I-87 (New York State Thru-Way) exit 19,
Kingston. R&R Cycle was started in 1979 by brothers Frank Rua & Henry Rua.
<br/>
<br /> As in many small businesses, it was launched out of the passion and enjoyment of the sport, along with the frustration with impersonal, overpriced corporate dealership attitude. With Frank's technical skills from his AMI (American Motorcycle
Institute) certification and Henry's business knowledge, R&R Cycle was born. In 1985 Steve Mulford joined our shop family. Steve also attended and became certified at AMI in Daytona Beach, Florida. He has a vast acquired knowledge of motorcycles
and ATVs. With almost 30 years of experience in real world shop situations, he has no equal in our area. Frank and Steve are both lifetime career mechanics, enthusiasts, and advocates for safe and responsible riding. We continue after almost
40 years to be small enough and personal, but yet large enough to attend to all your powersports needs. We have acquired a huge network of suppliers, vendors, and salvage yards all over the USA for hard to find items and parts. If you are in
our area please stop bye and say, Hi.</p>
</div>
</div>
<div class="slick-slidertwo">
<div class="a-slide" style="background: url('img/a1.JPG') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/a2.JPG') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/a3.JPG') no-repeat center center"></div>
</div>
</div>
<!-- End About Us -->
<!-- AOS: http://michalsnik.github.io/aos/ -->
<div class="wrap-service">
<a id="services"></a>
<div class="services">
<h1 style="font-size:45px;">A Business Built On Service.</h1>
<div class="service-images">
<div id="s1" class="slick-serviceone">
<div class="a-slide" style="background: url('img/s1.JPG') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/s2.JPG') no-repeat center center"></div>
<div class="a-slide" style="background: url('img/s3.JPG') no-repeat center center"></div>
</div>
</div>
<p data-aos="fade-up"> Our Business is built on service. Together, Frank and Steve have over 50 years of real world shop experience. They are both AMI (American Motorcycle Institute) Certified mechanics. We have been in the same location for over 30 years. Our goal is
to get the job done right the first time. Listening and understanding our customers and their needs is essential to achieving this goal.
<br />
<br />In addition to the usual tune ups, we sell and install hundreds of top name brand tires each season with state of the art mounting and computer tire balancing equipment. We are second to none for carburetor and electrical troubleshooting,
diagnosis, repair. Our new Ultrasonic carb cleaning tank does a great job. Complex electrical charging & ignition systems on modern units require accurate testing before expensive components are purchased. Whether its motorcycles or ATV's. </p>
</div>
<br />
<br />
<hr id="underline">
<div class="service-items">
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Complete engine overhauls- top end - bottom end</div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Transmission rebuilds - shift forks - gears - etc...</div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Wheel lacing & truing</div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Crankshaft rebuilding </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Fork tube straightening </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Cylinder boring/honing </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Valve reconditioning </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Front end alignment </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Accident damage </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Pre Purchase appraisal of used cycles / ATV's </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Pick Up & Delivery Available </div>
<div class="item" data-aos="flip-up"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Custom fabrication- lighting,wheels,fenders,exhaust, etc...</div>
</div>
<!-- Temp Break to see animation for all items -->
</div>
<div class="empty"></div>
<!-- Footer for Copyright and stuff like that, a little fame for me... -->
<div class="footer">
<p style="color:grey;">© 2017 R&R Cycle Inc. | Designed By Frank Rua. | frankselectronicmail#gmail.com</p>
</div>
<!-- End footer -->
<!-- --------------------------<Scripts>---------------------------------- -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="slick/slick/slick.min.js"></script>
<script src="js/slideshow.js" type="text/javascript"></script>
<script src="js/smoothscroll.js" type="text/javascript"></script>
<script src="js/banner.js" type="text/javascript"></script>
<script src="js/aso.js" type="text/javascript"></script>
</body>
</html>
I pulled the media queries from another site to speed that process up, but I've tried a couple different methods to transform my CSS and nothing is working. Including making my Text "Divs" smaller when the screen gets smaller but all that does is cut off the text more because the location changes. This is the last solution I tried was just transforming the body of the page using:
left: x%;
transform: translate(-x%, -x);
top: x%;
Which gave me no progress just a page that was split by a certain percentage. I've been reading articles on how to do this and I just can't get a grasp on it ;Responsive design is something I'm fairly new to and I'm not exactly sure how to transform this. Can somebody give me an example with this webpage so I can see?
Here's a Screenfly so you can see what I'm talking about, the text under "The Shop" is cut off.
Screenfly Example
I know it's easy to downvote a question like this, but I'd rather have someboyd give me a real life example with the webpage I'm working with and then an explanation not a generic example taken off the internet, which is what I'm struggling with at the moment. Thank you everyone!
Your media queries will not work, cause you not put any css selector to apply styles to. Please look this simple media queries example.
p{
font-family: arial,san-serif;
font-size: 13px;
font-color: black;
}
h1{
font-size:30px;
}
#media screen and (min-width:761px){
body{
background-color:white;
}
h1{
color:red;
}
}
#media screen and (max-width:760px){
body{
background-color: #333;
}
h1{
color:red;
}
p{
color: white;
}
}
#media screen and (max-width:480px){
body{
background-color: #807f83;
}
h1{
color:white;
}
p{
color: white;
}
}
#media screen and (max-width:360px){
body{
background-color: #0096d6;
}
h1{
color:white;
font-size:25px;
}
p{
color: white;
}
}
In media queries you should add css selector and then style rules to apply

How to prevent a button from moving when resizing the window

I can use some help as I am new to html coding. anyway,
I've made a carousel with bootstrap. The carousel itself works fine. But after placing a button in the carousel, (using top: (px) and right: (px) as I don't know how to place it where I want otherwise)it still works fine. Until I start resizing the window. The background becomes smaller, but the button kind of stays the same size. So it starts moving around and what once were 2 buttons next to eachother, are now 2 buttons with alot of space between them. Here, have a look at my code:
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width = device-width, initial-scale = 1">
<title>Galaxy</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
</style>
</head>
<body>
<div id="theCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#theCarousel" data-slide-to="0" class="active"></li>
<li data-target="#theCarousel" data-slide-to="1"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="galaxy3.jpg">
<div class="slide1"></div>
<div class="carousel-caption">
<div class="bannertext">
<h1>Santorodesign</h1>
<p>A website made by Michael</p>
<div class="mobileHide"> <button id="headerbutton-nederlands">Nederlands</button></div>
<div class="mobileHide"> <button id="headerbutton-english">English</button></div>
</div>
</div>
</div>
<div class="item">
<div class="slide2"></div>
<img src="galaxy2.jpg">
<div class="carousel-caption">
<div class="bannertext2">
<h1>Explore the galaxy<h1>
</div>
</div>
</div>
<a class="left carousel-control" href="#theCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#theCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
<div id="firstrow">
<div class="planet col-lg-4 col-md-4 col-sm-6 col-xs-12">
<img id="mercury" src="mercury.png"> <br>
(text) <br>
<button type="submit" class="btn-primary btn-lg">Learn more about Mercury</button>
</div>
<div class="planet col-lg-4 col-md-4 col-sm-6 col-xs-12">
<img id="earth" src="earth.png"> <br>
(text)<br>
<button type="submit" class="btn-primary btn-lg">Learn more about the Earth</button>
</div>
<div class="planet col-lg-4 col-md-4 col-sm-6 col-xs-12">
<img id="venus" src="venus.png"> <br>
(text) <br>
<button type="submit" class="btn-primary btn-lg">Learn more about Venus</button>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
CSS
.carousel-control.left, .carousel-control.right {
background-image: none
}
#firstrow {
font-size: 2em;
padding: 100px 0 0 0;
width: 100%;
height: 550px;
text-align: center;
color: black;
background: #DCDCDC;
position: relative;
}
#media all and (max-width: 900px) {
#headerbutton-nederlands { display: none; }
#headerbutton-english { display: none; }
}
.planet {
margin-bottom: 30px;
position: relative;
}
.planet img {
height: 300px;
max-width: none;
}
.bannertext {
font-size: 1.3em;
line-height: 15px;
}
.bannertext h1 {
font-size: 2em;
}
.bannertext2 {
font-size: 2em;
}
.mobileShow { display: none;}
.mobileHide { display: inline;}
/* Smartphone Portrait and Landscape */
#media only screen
and (max-device-width : 480px){
.mobileShow { display: inline;}
.mobileHide { display: none;}
.planet img{
height: 200px;
}
}
#headerbutton-nederlands {
position: absolute;
font-weight: bold;
bottom: 35px;
right: -90px;
-webkit-border-radius: 5px;
line-height: 50px;
color: white;
background-color: #778899;
width: 13%;
text-align: center;
border: white 2px solid ;
}
#headerbutton-english {
position: absolute;
font-weight: bold;
bottom: 35px;
right: 100px;
-webkit-border-radius: 5px;
line-height: 50px;
color: white;
background-color: #778899;
width: 13%;
text-align: center;
border: white 2px solid ;
}
basically what I want is that the buttons + the text inside of the buttons also resize when the window becomes smaller. As if the buttons are a part of the image.
Thank you for your time.
-Michael
If you want the buttons to scale relative to the size of the screen, you need to style them with relative units instead of pixels. You can use, % to size them relative to their parent element, em or rem to size them relative to the size of the font, or --most likely for your needs-- vh or vw to scale them relative to the height and width of the viewport, respectively.
Assuming your initial styles work on a viewport 1140px wide (just an arbitrary starting point), the following CSS may get you headed in the right direction:
#headerbutton-nederlands {
position: absolute;
font-weight: bold;
bottom: 3vw;
right: -8vw;
-webkit-border-radius: .5vw;
line-height: 4.3vw;
color: white;
background-color: #778899;
width: 13%;
text-align: center;
border: white 2px solid ;
}
You need to add position: relative; property to the .bannertext element. What this does is when a child element is absolutely positioned inside a relatively positioned parent, it makes sure the child element stays relative from the bounds of the parent. So change .bannertext in your CSS to the following and it should work.
.bannertext {
font-size: 1.3em;
line-height: 15px;
position: relative;
}
You may need to update the top and right properties though so it's back in the right place you wanted again.

Font media queries not working

I am trying to make some text responsive. For some reason, media queries are not working and the font is pushed below the image, whereas it should be above.
Here is my code:
// Bootstrap callback test
if ($('#bootstrapCssTest').is(':visible') === true) {
$('<link href="/bootstrap/js/bootstrap.min.js" rel="stylesheet" type="text/css" />').appendTo('head');
}
// Make .navbarButtonDiv go to its child 'a' tag's href on click
$(".navbarButtonDiv").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
// Collapse navbar on nav link click
$(document).on('click', '.navbar-collapse.in', function(e) {
if ($(e.target).is('a')) {
$(this).collapse('hide');
}
});
// Collapse navbar on document click
$(document).on('click', function() {
$('.collapse').collapse('hide');
});
/* Font imports */
#import url(https://fonts.googleapis.com/css?family=Bitter:400,400italic,700);
#font-face {
font-family: "FuturaNewLight";
src: url("fonts/FuturaNewLight.otf")
}
/* Navbar padding */
body {
padding-top: 100px;
overflow-x: hidden !important;
}
/* Navbar */
.navbar {
font-family: "Bitter", serif;
}
.navbar.navbar-custom .navbar-brand.navbar-brand-centered {
position: absolute;
left: 50%;
top: 0;
display: block;
width: 100px;
text-align: center;
padding: 0;
}
.navbar.navbar-custom > .wrapper .navbar-brand.navbar-brand-centered {
margin-left: -55px;
margin-top: 10px;
}
.navbar .nav.navbar-nav {
font-size: 150%;
}
.navbar-logo {
height: 145%;
}
/* Media queries */
#media (min-width: 768px) {
.wrapper {
padding-right: 15px;
}
.navbar.navbar-custom .navbar-nav > li > a {
line-height: 60px;
transition: background 200ms linear;
}
.navbar.navbar-custom .navbar-nav > li > a:hover {
background: #96D5FF;
}
}
#media (max-width: 767px) {
.navbar.navbar-custom {
padding: 20px 0;
}
.navbar.navbar-custom .navbar-collapse {
margin: 20px 0 -20px;
border: none;
box-shadow: none;
height: 260px;
}
.navbar.navbar-custom .navbar-nav > li > a {
text-align: center;
}
.navbar-logo {
margin-left: 20px;
height: 110%;
}
.futuraNewLightHeader {
font-size: 20px;
}
}
/* Header styling */
#jumbotronHeader {
position: relative;
font-family: "Bitter", serif;
width: 100%;
bottom: 9px;
}
#homePageImage {
position: relative;
-webkit-filter: blur(5px);
filter: blur(5px);
bottom: 30px;
z-index: -1;
width: 70%;
}
/* Font styling */
.futuraNewLightHeader {
position: absolute;
top: 550px;
font-size: 150px;
width: 100%;
color: White;
text-shadow: 2px 2px Black;
font-family: "FuturaNewLight";
}
.futuraNewLightSubHeader {
position: absolute;
top: 750px;
font-size: 60px;
width: 100%;
color: White;
text-shadow: 2px 2px Black;
font-family: "FuturaNewLight";
}
#dynamicHeaderText {
color: #2099FF;
}
/* General styling */
.centerText {
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Education for Everyone</title>
<link rel="icon" type="image/png" href="images/edufeLogo.png">
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="container-fluid">
<nav class="navbar navbar-default navbar-fixed-top navbar-custom" role="navigation">
<div class="wrapper">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#js-navbar-collapse"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<a class="navbar-brand navbar-brand-centered" href="#/">
<img class="navbar-logo" src="images/edufeLogo.png">
</a>
<div class="collapse navbar-collapse" id="js-navbar-collapse">
<ul class="nav navbar-nav navbar-left">
<li>Home
</li>
<li>About
</li>
<li>Learn
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Log In
</li>
<li>Sign Up
</li>
</ul>
</div>
</div>
</nav>
<!-- Jumbotron -->
<div class="jumbotron" id="jumbotronHeader">
<h1 class="display-3 centerText">Education for Everyone</h1>
<p class="lead centerText">Learn. Create. Share.</p>
<hr class="m-y-3">
</div>
<!-- Image header -->
<div class="imageHeader">
<span class="futuraNewLightHeader centerText"><span id="dynamicHeaderText">Learn</span> something new.</span>
<span class="futuraNewLightSubHeader centerText">From the internet to real life.</span>
</div>
<img src="images/homePageImage.png" id="homePageImage" class="center-block img-responsive">
</div>
<!-- Script tags -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
Thanks! Any help is appreciated!
Move all text formatting options into the media queries and try then.
First you need set #media queries to #media screen and (max-width: ....).
Some cases browsers need screen parameter.
Second, you need change font size of elements when responsive. I suggest using em unit to make responsive.

How to change navbar background color after page has scrolled down

I have a fixed navbar on a bootstrap project and on the landing page of the website, I have made the background of the navbar transparent. When the website scrolls down, I want the navbar background to change back to black. I am using bootstrap. An example of what I want can be seen in the nabber at :
http://ironsummitmedia.github.io/startbootstrap-agency/
I am a new coder, so I apologize for any mistakes in the code formatting.
HTML:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Youth | Society</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="design.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<img src="1.png">
</div>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>Who are we</li>
<li>Volunteer</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</header>
<div class="page1">
<div class="landing">
<div class="container">
<h1>Peel's YES</h1>
<p>Welcome To Peel's Youth Engagement Society</p>
</div>
<div class="topics">
<div>
<div class="row">
<div class="col-md-4">
<h3>Learn</h3>
<p>Get to know more about YES, who we are, and what we do.</p>
</div>
<div class="col-md-4">
<h3>Volunteer</h3>
<p>Find out how you can get involved! YES strives to prove YOUth with unique opportunities and experiences.</p>
</div>
<div class="col-md-4">
<h3>Educate</h3>
<p>Read about the themes that YES has supported in the past</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</DOCTYPE>
CSS:
.navbar-header {
display: inline;
}
.navbar{
background: transparent;
background-color: transparent;
border-color: transparent;
}
#media screen and (max-width: 767px) {
.navbar {
background-color: black;
}
}
.navbar-toggle{
margin-top: -50px;
}
.navbar .nav > li > a {
color: black;
}
#media screen and (max-width: 767px) {
.navbar .nav > li > a {
color:white;
}
}
.navbar {
padding-top:15px;
padding-bottom: 5px;
}
#media screen and (max-width: 767px) {
.navbar {
padding-top:0px;
padding-bottom: 0px;
}
}
.navbar a {
font-size: 13px;
font-weight: bold;
text-transform: uppercase;
}
.navbar li{
font-family: 'Lato', sans-serif;
display: inline;
}
.navbar img {
max-height: 50px;
margin-top: -20px;
}
/* P A G E 1 */
.landing {
padding-top:140px;
background-image:url(mainpage1.JPG);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 760px;
}
.landing h1 {
text-align: center;
color: #000;
font-size: 70px;
font-family: 'Lato', sans-serif;
font-weight: bold;
}
.landing p {
text-align: center;
font-size: 20px;
color: #000;
font-family: 'Lato', sans-serif;
}
.topics{
background: #eeeeee;
padding-right:40px;
margin-top: 340px;
text-align: center;
}
.topics h3{
font-size: 18px;
}
.topics p{
font-size: 18px;
}
/* P A G E 2 */
.page2 {
height:760px;
}
.page2 h3{
text-align: left;
margin-top: 100px;
}
Here is a Fiddle to view.
I made a change the have the shade color of the nav also show in smaller screens if this helps you.
If you come across this post and view the Fiddle, make sure you make the view frame lager.
This navbar effect is for large screens. (768 px Plus) Large view FIDDLE here.
You can change when the effect happens as you scroll from the top here.
var docElem = document.documentElement,
header = document.querySelector( '.navbar-default' ),
didScroll = false,
changeHeaderOn = 200;
The background color is changed by this here
.navbar-default.navbar-shrink {
padding: 10px 0;
background-color: #222567;
background: rgba(70,10,200,0.9);
And the background color is first set by this here.
#media(min-width:768px) {
.navbar-default {
padding: 25px 0;
border: 0;
/* background-color: transparent; */
background: rgba(70,10,200,0.4);
-webkit-transition: padding .3s;
-moz-transition: padding .3s;
transition: padding .3s;
}
There are many scripts out there for animating things on scroll. Honestly, it really depends on that you want to do. Here is a jQuery script that shows the basics. It simply adds a class to navbar (or whatever you want) once the visitor has scroll past a certain point. On the class, in this case shrink, I usually add transition easing to the class which makes things transition nicely when adding/removing the class.
$(window).scroll(function() {
if ($(this).scrollTop() > 200){ // Set position from top to add class
$('.navbar').addClass("shrink");
} else {
$('.navbar').removeClass("shrink");
}
});

Need help centering social media icons in the a footer on a website

I have been stuck on something very simple for over a day now and I have to ask for help. I am trying to do something simple as centering vertically my social media icons in my footer. I tried to take the same route when someone helped me with the Navigation Bar but I just cannot seem to grasp/understand something to get the same result.
I thought about doing padding but I was not sure if that still would take care of re-sizing or smaller screens, so I wanted to take more a percent route instead of flat amount.
Website for Inspect
Footer HTML:
<!-- Social Media + Footer -->
<div class="container">
<div class="navbar navbar-fixed-bottom">
<div class="collapse navbar-collapse">
<div class="row">
<div class="col-md-12">
<ul class="nav navbar-nav">
<li>
<img src="link/ico-facebook.png"
alt="Facebook Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
<li>
<img src="link/ico-twitter.png"
alt="Twitter Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- End of Social Media + Footer -->
CSS:
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.navbar-fixed-bottom {
bottom: 0;
margin-bottom: 0;
border-width: 0 0 0;
position: relative;
right: 0;
left: 0;
z-index: 1030;
-webkit-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.navbar {
position: relative;
min-height: 100px;
margin-bottom: 20px;
border: 1px solid transparent;
}
.navbar-collapse.collapse {
display: block!important;
height: auto!important;
padding-bottom: 0;
overflow: visible!important;
}
#media (min-width: 768px) .navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-collapse {
text-align: center;
padding-right: 15px;
padding-left: 15px;
overflow-x: visible;
-webkit-overflow-scrolling: touch;
border-top: 1px solid transparent;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
}
.collapse {
display: none;
}
#media (min-width: 768px).navbar-nav {
display: inline-block;
float: none;
vertical-align: middle;
margin: 0;
}
.navbar-nav {
margin: 7.5px -15px;
text-align: center;
}
.nav {
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
#media (min-width: 768px).navbar-nav>li {
display: inline-block!important;
}
.nav>li {
position: relative;
display: inline-block!important;
}
img.element.style {
width: 100%;
height: auto;
max-width: 32px;
}
img {
vertical-align: middle;
}
You could do it by apply some custom CSS to your HTML elements:
<div class="navbar navbar-fixed-bottom" style="display: table !important; width: 100%;">
<div class="collapse navbar-collapse" style="vertical-align: middle;display: table-cell !important;">
......
......
</div>
</div>
I was the one who answered you the first time, so here I go again to make sure you understand how it works.
First, let's do a tiny change in your HTML markup, as follows:
<!-- Social Media + Footer -->
<div class="container">
<div class="navbar navbar-fixed-bottom">
<div class="collapse navbar-collapse vertimid">
<div class="row">
<div class="col-md-12">
<ul class="nav navbar-nav">
<li>
<img src="link/ico-facebook.png"
alt="Facebook Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
<li>
<img src="link/ico-twitter.png"
alt="Twitter Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- End of Social Media + Footer -->
If you pay attention, I have only added the class .vertimid to the line
<div class="collapse navbar-collapse">
we do this in order to accurately target that class so you can re-use it later, as I told you the other day.
Now, you do add this property to
.navbar-collapse.vertimid{display:inline-block} /* replaces display:table */
and that's it.
Remember: you need to vertical align elements relative to the container block. Also, as we're at it, be sure to check your site in Firefox, because you'll find out your social media icons aren't there
Decide what height percentage of the footer you want your social media icons to be...suppose 30%:
ul.nav {
height:30%;
margin-top:35%;
margin-bottom:35%;
}