How to scale jumbotron bootstrap on larger monitors? - html

I currently have a website that uses the jumbotron feature from bootstrap taken from the Codecademy "how to make a website" tutorial.
In it, it uses the following html:
<div class="jumbotron">
<div class="container">
<h1>Heading</h1>
<p>Tagline</p>
<button type="button" class="btn btn-lg btn-danger">Learn More</button>
<!--Learn More-->
</div>
</div>
and the following CSS:
.jumbotron {
background-image:url("flight.jpg");
height: 500px;
background-repeat: no-repeat;
background-size: cover;
margin-bottom:0px;
}
.jumbotron .container {
position: relative;
top:100px;
}
.jumbotron h1 {
color: #CC0000;
font-size: 48px;
font-family: 'Shift', sans-serif;
text-shadow:none;
}
.jumbotron p {
font-size: 20px;
color: #CC0000;
text-shadow:none;
}
The background image is not scaling properly when a larger monitor is used, and the image increases in size within the div, but the div stays the same size. The result looks like a zoom on the image rather than the image staying whole.
Any idea how to make it scale properly on larger monitors?

Change to
Oh I apologive for misunderstanding your question you need to edit the css for .jumbotron needs to be cover and position to center.
.jumbotron { background-size: cover; background-position: center; }
Add Container Div around Jumbotron!
<div class="container">
<div class="jumbotron">
<div class="container">
<h1>Heading</h1>
<p>Tagline</p>
<button type="button" class="btn btn-lg btn-danger">Learn More</button>
<!--Learn More-->
</div>
</div>
</div>

UPDATE 2:
This is helpful link. I think, your solution in jQuery.
UPDATE:
Here is solution.
background: url("flight.jpg") no-repeat center center;
height: 500px;
background-repeat: no-repeat;
background-size: 100%;
margin-bottom: 0px;
}
You can use #media query like this:
#media (max-width: 768px) {
.btn-responsive {
padding:2px 4px;
font-size:11px;
line-height: 1;
border-radius:3px;
}
}
#media (min-width: 769px) and (max-width: 992px) {
.btn-responsive {
padding:4px 9px;
font-size:12px;
line-height: 1.2;
}
}
With a #media query, you can write different CSS code for different
media types.
This helps when you want different layout for different media types
such as a screen or a printer, but also when you want different layout
for different devices, which is very useful when making web pages with
responsive design.
You can also have different layout when a user resizes the browser
window up or down to a certain width, or height.
More info.

Related

Responsive Background Image (And keeping Text centered in the middle of that)

I am trying to code up a banner with a minimal amount of media queries, as in the past for header images and text, I can't figure out a way to use anything under 10.
My current issue:
I have a responsive background image that looks like this:
Header Image
However as the browser resizes, although the background image is being responsive, the container within the background div that houses the text is not resizing, therefore not keeping the text centered in the middle.
You can see something like this is happening:
Container overflowing
I've tried all kinds of things, heights on containers, removing heights. But all areas I end up getting to, I am having to do too many media queries to fix the text, or change the height of the image instead as the screen size goes down. I'd like to try and learn how to code a better header for this website that is more flexible and intuitive, that I can carry over too my future projects.
Here is the code HTML:
<section class="home_banner">
<?php
$featuredimage = get_the_post_thumbnail_url();
?>
<div class="banner_image" style="background-image: url('<?php echo $featuredimage; ?>'); ">
<div class="container">
<div class="banner_text_inner">
<p>Lorem Ipsum</p>
<div class="banner_excerpt">
<h1>Powerful engaging opening title</h1>
</div>
</div>
</div>
</div>
</section>
Here is the css:
.home_banner{
.banner_image {
background-size:100%;
height:100rem;
background-repeat: no-repeat;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
text-align: center;
.banner_text_inner {
max-width: 1000px;
width: 100%;
margin: auto;
padding: 0 10px;
box-sizing: border-box;
font-family: $autumnchant;
font-size: 40px;
color: $color-primary;
#media (max-width: 1000px){
font-size: 30px;
p {
margin-bottom: 0;
}
}
#media (max-width: 400px){
font-size: 22px;
}
}
.banner_excerpt {
#media (max-width: 1000px){
h1 {
font-size: 40px;
}
}
#media (max-width: 400px){
h1 {
font-size: 30px;
line-height: 1;
letter-spacing: 5px;
margin-bottom: 0;
}
}
}
}
}
Try to add "background-size: cover;" to your banner-image and also add min-height.

Footer comes up in smaller screens

I've a html page wherein I display a table with data from the database along with a footer at the bottom of the page.
The problem is that with smaller screens (around less than 760px) the footer, instead of being at the bottom, goes upwards and thus overlaps and hides a portion of the display data.
I want that irrespective of the screen size, the footer should always be placed at the bottom of the page.
My code snippets are mentioned below. Request you to please provide a solution.
Edit 1: A (static) scenario is available at the codepen url (please check out for smaller screen sizes): http://codepen.io/abbor123/pen/YGwVXg
The footer element:
<div class="footer">
<div class="container">
<p>Designed & Created by AB </p>
<p><i class="fa fa-lg fa-creative-commons" aria-hidden="true"></i> Some Rights Reserved </p>
</div>
</div>
CSS:
.footer
{
clear: both;
position: relative;
z-index: 10;
height: 8em;
margin-top: -5em;
padding-top: 2.5em;
background: #009933;
text-align: center;
}
body
{
background:url(image.png) no-repeat center center fixed;
background-size: cover;
font-family: 'Exo 2', sans-serif;
color: black;
}
#media (max-width: 770px)
{
#table-display
{
font-family: 'Exo 2', serif;
text-shadow: 4px 4px 4px #aaa;
text-align: left;
color: black;
margin-top: 60px;
border-collapse: collapse;
width: 100%;
}
}
To fix the footer problem, remove the height: 60em; from the .row class. It's at line 68 in the CSS for CodePen. http://codepen.io/FluidOfInsanity/pen/gwvZLN?editors=1100
Also, would you want to remove the top: 6px; from the td:before? Maybe your example is just a quick mock-up, but it throws off my example.

HTML/CSS Make image resize on smaller screens

I'm trying to build a very basic site with an image centered in the middle of the page with three lines of text below it, also centered.
I have it how I want it to look on a larger screen, but when viewed on a smaller screen (iPhone) the image is too large. I need to have the image resize based on the screen resolution.
I've done some Google'ing and know this is possible, but have not been able to get it to work. HTML/CSS is not my strong suite. Any help would be much appreciated. Here is my code:
<html>
<style>
body {
font-family: 'Helvetica', 'Arial', sans-serif;
background: white }
section {
background: white;
color: black;
border-radius: 1em;
padding: 1em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%) }
</style>
<section>
<IMG src="Logo.png" alt="Logo">
<br><br>
<h1><center><p>Email
<p><font color=B5B5B5>Phone Number
<font size=7> <p><i>Tagline</i></center></font>
</section>
</html>
You can use media queries. Try to add the following code in your CSS.
CSS:
#media screen and (max-width: 480px) {
img {
width: 400px;
}
}
Once the browser is at 480px, it will make the img width 400px. You can change these numbers to suit your preference.
You need to look into setting up fluid images, this will help you get started...
CSS Fluid Image Technics
Here is an example...
HTML
<section class="container">
<img src="http://placehold.it/750x250">
<div class="copy">
Email
<p>
<span class="phone-number">Phone Number</span><br />
<span class="tagline">Tagline</span>
</p>
</div>
</section>
CSS
body {
font-family: 'Helvetica', 'Arial', sans-serif;
background: white
}
.container {
bottom: 0;
left: 0;
height: 300px;
margin: auto;
position: absolute;
right: 0;
text-align: center;
top: 0;
width: 100%;
}
.container img {
max-width: 100%;
}
https://jsfiddle.net/kennethcss/71a6mngh/
The image is centered (using absolute centering), and when you drag the browser in the image automatically adjust it's size...this is how fluid images behave (no need for media queries per se). If you still need a media query you can do something like this...
https://stackoverflow.com/a/39760016/4413798
https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
You need to add a max-width to the image:
img {
max-width: 100%;
}
just off topic: <h1><center><p>..</p></center></h1> is invalid. Just use <h1>..</h1> and style it.
<font> is also invalid and deprecated (just like center)
Try something as below, there were few error in your codes, you could style your HTML elements by adding style tag in your targeted HTML element or by adding external or internal CSS files. Well now to make it responsive use CSS media query as below, define breakpoints where you need your image to change.
#media screen and (max-width : 480px){
.......
.......
.......
}
#media screen and (max-width : 320px){
.......
.......
.......
}
body{
background:#fff;
}
#box{
width:70%;
height:300px;
margin:auto;
margin-top:20%;
}
#box > .bximg{
width:180px;
height:180px;
overflow:hidden;
margin:auto;
}
#box > .bximg > img{
width:100%;
min-height:100%;
}
#media screen and (max-width: 480px){
#box > .bximg{
width:120px;
height:120px;
}
}
<div id="box">
<div class="bximg">
<img src="https://source.unsplash.com/random">
</div>
<h1 style="text-align:center;margin:0px;">
Email</h1>
<p style="text-align:center;margin:10px 0px; "><font color=B5B5B5>Phone Number</font>
<p style="text-align:center;margin:10px 0px;"><i>Tagline</i></p>
</div>
You can use max-width for <img> element.
section img {
max-width: 100%;
}
You're going to want to take a look at media queries in the Mozilla docs.
https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
There's a link to help you get a better understanding of it but basically the web content will resize based on the size of the screen.

background image not being responsive

The dev site is located at http://www.clhdesigns.com/cliwork/wintermeresod/about.php
The issue I'm having is if you take a look at the home page the background images scales perfectly while on the about us page it doesn't at all. What I'm looking for is a 100% scale down here is the code that I have.
<div id="main" class="about">
<div class="inner">
<div class="welcome_intro2">
<h1>Growing Top Quality Sod</h1>
<h2>for over 25 years</h2>
</div>
And now here is the corresponding CSS
#main { float:left; width:100%; padding:1em 0 3em 0; color:#666;}
.about {
background: url("../images/banner3010.jpg") no-repeat;
height:582px;
width:100%;
}
What I'm looking for is to keep the height of the image in the desktop where it is but I need it to be 100% responsive. Any ideas?
Take a look.
.about {
background: url("../images/banner3010.jpg") no-repeat 50% 50%;
height:582px;
}
here is a SCREENSHOT of how it works. I have used the same code that has the image in the first page and this is what made it responsive. Check code below
.about {
background: url("../images/banner3010.jpg") center center no-repeat;
height:582px;
}
You can use #media queries for tablet and mobile phone image height
#media screen and (max-width: 768px) {
.about {
height:300px; /*whatever height you want*/
}
}

Fix web page as per the screen resolution

I am designing a webpage that does not adjust itself as per the screen resolution. It looks OK on higher resolutions but on 1024x768, only the left side of the page is visible. I have tried out putting the whole thing in a container and aligning it to the center but it doesnt work. What would be a way out?
Here's a bit of the HTML:
<div id="layer-container" style="position:absolute; background- image:url(images/bkgrd_final.jpg);">
<div id="info-layer" style="position: absolute; text-align: left; left: 0px; top: 2px; height: 747px; z-index: 48; display: block; margin:0 0 0 -285px;" title="">
And here is some CSS:
div#container {
position:absolute;
margin:0 auto;
text-align:left;
overflow:visible;
}
body {
font-size: 8px;
line-height: 1.1875;
text-align: center;
margin: 0;
background-color: #0C0C0C;
background-repeat: repeat-x;
background-position: center top;
color: #000000;
overflow-x:hidden;
}
I would sugest you add mediaqueries with styles for smaller devices.
#media only screen and (max-width: 768px) {
even better: go "mobile first" by designing you page for mobile devices. then add media-queries with extra styles for bigger devices.