So I have this small webpage I am trying to build. Everything looks good til I try to scale-in and out the browser windows to check it's responsiveness.
It looks good with 320x568 as below.
But when it scaled in (reduce the browser window, it shows like this, which I don't want that black box (`.transbox) to go down beyond the photo.)
I am using bootstrap framework and I DON'T NEED TO USE css media queries to make it responsive.
How can I do it with css instead?
This is my current html and css
.masthead {
height: 20vh;
min-height: 370px;
background-image: url("http://lorempixel.com/1920/1080");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
div.transbox {
margin: 30px;
background-color: rgba(0, 0, 0, 0.6);
min-height: 300px;
}
div.transbox p {
font-weight: bold;
color: white;
}
.transbox h1 {
color: white;
}
<header className="masthead">
<div className="container">
<div className="row align-items-center">
<div className="col-12 text-center">
<div class="transbox">
<h1 className="font-weight-light">
All your Escort needs within a single place!
</h1>
<p className="lead">
Find the best set of escort services in Sri Lanka
</p>
</div>
</div>
</div>
</div>
</header>
Can someone please help me? Is there a bootstrap class or pure css way to do this?
Here is the working example:
body {
margin: 0;
padding: 0;
}
.masthead {
width: 100%;
height: 100%;
min-height: 100vh;
background-image: url("http://lorempixel.com/1920/1080");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
display: flex;
align-items: center;
}
div.transbox {
margin: 30px;
background-color: rgba(0, 0, 0, 0.6);
min-height: 300px;
}
div.transbox p {
font-weight: bold;
color: white;
}
.transbox h1 {
color: white;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<header class="masthead">
<div class="container">
<div class="row align-items-center">
<div class="col-12 text-center">
<div class="transbox">
<h1 class="font-weight-light">
All your Escort needs within a single place!
</h1>
<p class="lead">
Find the best set of escort services in Sri Lanka
</p>
</div>
</div>
</div>
</div>
</header>
.masthead {
height: 20vh;
min-height: 400px;
background-image: url("http://lorempixel.com/1920/1080");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
div.transbox {
margin: 30px;
background-color: rgba(0, 0, 0, 0.6);
min-height: 300px;
}
div.transbox p {
font-weight: bold;
color: white;
}
.transbox h1 {
color: white;
}
<header className="masthead">
<div className="container">
<div className="row align-items-center">
<div className="col-12 text-center">
<div class="transbox">
<h1 className="font-weight-light">
All your Escort needs within a single place!
</h1>
<p className="lead">
Find the best set of escort services in Sri Lanka
</p>
</div>
</div>
</div>
</div>
</header>
Your content is more as compare to width of background image. So, just increase the height of your background image or just reduce the font-size via media query.
Related
When I try to preview my page on mobile devices the second col on the right is moved under the first col as it should be. The problem is that the whole content on my site is moved/pushed up and text (TAXI) is not visible.
PC
On phone it looks like this
PHONE
Here is code of the columns. What can I do for fixing it?
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<section id="mainpage">
<div class="container d-flex align-items-center justify-content-center info">
<div class="row mb-5">
<div class="col-12 col-md-6 my-auto">
<h1 class="text-uppercase text-white">TAXI VÍTKOV</h1>
<h6 class="text-white lead text-uppercase">Potřebujete svést? Zavolejte.</h6>
<h1 class="phone-number">777 996 166</h1>
<p class="text-white">Potřebujete se rychle a pohodlně dostat z bodu A do bodu B? Překvapil Vás déšť, sníh nebo jiná komplikace? Odvezeme Vás kamkoliv, kdykoliv. Bezpečně a spolehlivě.
</p>
</div>
<div class="col-12 col-md-6 d-flex align-items-center justify-content-center">
<div class="card-deck mb-3">
<div class="card mb-4 box-shadow">
<div class="card-header text-center">
<h4>Jízda již za</h4>
</div>
<div class="card-body">
<h1 class="card-title pricing-card-title">30kč/km</h1>
<table>
<tbody>
<tr>
<td>Čekání na zákazníka</td>
<td>4kč/min</td>
</tr>
<tr>
<td>Znečištění vozidla</td>
<td>**kč</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
* {
padding: 0;
margin: 0;
}
body {
background-color: #fff;
font-family: "Poppins", sans-serif;
}
html {
scroll-behavior: smooth;
}
#top-page .top-page-image {
background: url("https://patrikderka.cz/taxi_vitkov/doplnky/images/menu-top.jpg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 20px;
}
#bottom-page .bottom-page-image {
background: url("https://patrikderka.cz/taxi_vitkov/doplnky/images/bottom-photo.png");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 20px;
}
#mainpage {
height: 100vh;
min-height: 500px;
background-image: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.9)), url("https://patrikderka.cz/taxi_vitkov/doplnky/images/banner.jpg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
#mainpage .info {
height: 100%;
}
#mainpage .info h1 {
color: #f9d700;
font-size: 60px;
font-weight: bold;
}
#mainpage .card-header {
background-color: #f9d700;
}
#mainpage .card-body {
background-image: linear-gradient(rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.95)), url("https://patrikderka.cz/taxi_vitkov/doplnky/images/taxi-pattern.jpg");
background-repeat: repeat;
background-size: cover;
background-position: center;
color: #fff;
}
#mainpage .card-body h1 {
font-weight: 500;
}
#mainpage .card-body table {
border-collapse: collapse;
width: 100%;
}
So I tried to make it in different way. Using vh-100.
Problem is, that it leaves me a big white space on the bottom of the page.
space on the bottom
code
<section id="top-page">
<div class="top-page-image">
</div>
</section>
<section id="mainpage">
<header class="masthead">
<div class="container info h-100">
<div class="row h-100 align-items-center">
<div class="col-12 col-md-6">
<h1 class="text-uppercase text-white">TAXI VÍTKOV</h1>
<h6 class="text-white lead text-uppercase">Potřebujete svést? Zavolejte.</h6>
<h1 class="phone-number">777 996 166</h1>
<p class="text-white">Potřebujete se rychle a pohodlně dostat z bodu A do bodu B? Překvapil Vás déšť, sníh nebo jiná komplikace?
Odvezeme Vás kamkoliv, kdykoliv. Bezpečně a spolehlivě.
</p>
</div>
<div class="col-12 col-md-6 price d-flex justify-content-center align-items-center">
<div class="card-deck mb-3">
<div class="card mb-4 box-shadow">
<div class="card-header text-center">
<h4>Jízda již za</h4>
</div>
<div class="card-body">
<h1 class="card-title pricing-card-title">30kč/km</h1>
<table>
<tbody>
<tr>
<td>Čekání na zákazníka</td>
<td>4kč/min</td>
</tr>
<tr>
<td>Znečištění vozidla</td>
<td>**kč</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
</section>
* {
padding: 0;
margin: 0;
}
body {
background-color: #fff;
font-family: "Poppins", sans-serif;
height: 100%;
}
html {
scroll-behavior: smooth;
}
#top-page .top-page-image {
background: url("https://patrikderka.cz/taxi_vitkov/doplnky/images/menu-top.jpg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 20px;
}
#bottom-page .bottom-page-image {
background: url("https://patrikderka.cz/taxi_vitkov/doplnky/images/bottom-photo.png");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 20px;
}
#mainpage .masthead {
height: 100vh;
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.9)), url("https://patrikderka.cz/taxi_vitkov/doplnky/images/banner.jpg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
#mainpage .info h1 {
color: #f9d700;
font-size: 60px;
font-weight: bold;
}
#mainpage .card-header {
background-color: #f9d700;
}
#mainpage .card-body {
background-image: linear-gradient(rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.95)), url("https://patrikderka.cz/taxi_vitkov/doplnky/images/taxi-pattern.jpg");
background-repeat: repeat;
background-size: cover;
background-position: center;
color: #fff;
}
#mainpage .card-body h1 {
font-weight: 500;
}
#mainpage .card-body table {
border-collapse: collapse;
width: 100%;
}/*# sourceMappingURL=styles_taxi.css.map */
You should use the #media Rule in the CSS part. The #media rule is used in media queries to apply different styles for different media types/devices. This will help you to get rid of this and any query regarding different devices.
I fixed it with #media rule height: auto;.
I am making a website which has a certain background image. When it changes screen size i need the middle part of an image do be removed so the graphic would look slimmer . Here is the picture.
This is how it is now :
This is how i need it when the screen is changed to tablet :
My html :
<section class="hero" style="background-image: url(./images/hero.png)">
<header class="header">
<img src="./images/logo.png" alt="Logo image" class="logo">
<div class="shape hamburger">
<!-- <span class="hide">Hamburger icon</span> -->
<a class="line-shape" href="javascript:;"><span></span><span class="hide">Hamburger icon</span></a>
<span class="shape-txt" >MENU</span>
</div>
</header>
<div class="row">
<div class="col col-2 offset-2 col-2-t offset-2-t">
<h1 class="section-title">
Living our values
Transforming our business
</h1>
<p class="txt">
UDG Healthcare plc</br>
Annual Report and Accounts 2015
</p>
<span class="s s-down-arrow"><span class="hide">download</span></span>Download Full Report <span class="no-under">(PDF, 2.5 MB)</span>
</div>
</div>
<span class="above-btn">Explore our year</br>
in review</span>
<button type="button" class="down"><img src="./images/down.png" alt="Move to the top content"><span class="s s-down-arrow btn-arrow"><span class="hide">Move Down</span></span></button>
My css :
.hero {
background-repeat: no-repeat;
background-size: cover;
background-color: $hero-bg-cream;
overflow: hidden;
.row {
margin: 0;
}
h1 {
padding: 106px 0 7px;
line-height: 1.15;
word-spacing: 5px;
letter-spacing: 0px;
width: 70%;
font-size: 40px;
color: $grey;
}
.txt {
line-height: 19px;
padding-bottom: 14px;
color: $grey;
}
.padded {
padding-bottom: 421px;
}
.s-down-arrow {
&:last-child {
left: -38px;
color: $grey;
top: 0;
}
}
.above-btn {
font-size: 14px;
text-align: center;
display: block;
padding-bottom: 16px;
color: $grey;
}
.down {
transform: translateX(13%);
}
#include breakpoint (tablet) {
h1 {
font-size: 29px;
padding: 217px 0 7px;
}
.txt {
padding-bottom: 10px;
}
.padded {
padding-bottom: 308px;
}
.down {
transform: translateX(10%);
}
}
}
I guess I would need to remove the right part of the image or something like that ?
Ok so the solution was to make the background-size: auto;
You can do this here in HTML :
<section class="hero" style="background-image: url(./images/hero.png); background-size: 100% 100%;">
Or here, in CSS
.hero {
background-repeat: no-repeat;
background-size: 100% 100%;
background-color: $hero-bg-cream;
overflow: hidden;
.row {
margin: 0;
}
I apologize in advance for this somewhat lengthy explanation. I am trying to create a website such as http://melaniedaveid.com/ to improve my coding abilities. I created the first section page and it turned out great. But when I added another section, the previous section didn't fill up the whole page anymore (picture: http://imgur.com/a/EbUKn).
In order to solve this I gave full height to the first sections ID:
#header {
height: 100%;}
This fixed the problem(http://imgur.com/a/BlckC) but now when I resize my browser the second section over flows into my first, covering the text(http://imgur.com/a/C1jED). Any suggestions/leads would be greatly appreciated!
body {
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('/img/roses.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
font-size: 20px;
height: 100vh;
}
/*------------------------------------------------ HOME PAGE ------------------------------------------------------------------*/
/*------------------------------
HEADING TEXT
-------------------------------*/
.name h1 {
font-family: 'Muli', sans-serif;
font-size: 500%;
font-weight: 300;
text-align: center;
padding-top: 10%;
color: #ecf0f1;
font-family: 'Cormorant Garamond', serif;
}
.name p {
font-family: 'Play', sans-serif;
font-size: 130%;
text-align: center;
padding-top: 5%;
color: #ecf0f1;
font-family: 'Merriweather', serif;
font-weight: 300;
padding-right: 10%;
padding-left: 10%;
}
/*------------------------------
Nav Bar
-------------------------------*/
.navigation p {
display: inline;
font-family: 'Play', sans-serif;
color: #ecf0f1;
}
.navigation {
text-align: center;
padding-top: 15%;
}
.contents,
.contents:hover {
text-decoration: none;
color: #ecf0f1;
font-family: 'Delius Unicase', cursive;
}
/*------------------------------------------------ ABOUT PAGE ------------------------------------------------------------------*/
/*------------------------------
About Heading
-------------------------------*/
#about {
background-color: black;
background-size: cover;
height: 100%;
}
#header {
height: 100%;
}
<section id="header"> <!------------------------- HOME PAGE -------------------------->
<div class="container">
<div class="row">
<div class="col-xs-12 name">
<h1>Temple Naylor</h1>
</div>
</div>
<div class="row">
<div class="col-xs-12 name">
<p>I create Web-designs with a sense of Feng-Shui in mind; resulting for a intuitive, responsive, harmonious, experience for users across the world.</p>
</div>
</div>
<div class="row">
<div class="col-xs-12 navigation hidden-sm-down">
<p><a class="contents" href="#">ABOUT</a> / </p>
<p><a class="contents" href="#">WORK</a> / </p>
<p><a class="contents" href="#">CONTACT</a> / </p>
<p><a class="contents" href="#">PHOTOGRAPHY</a></p>
</div>
</div>
</div>
</section>
<section id="about"> <!------------------------- ABOUT PAGE -------------------------->
<div class="container">
<div class="row about">
<div class="col-md-6">
<p class="big-text"></p>
</div>
</div>
<div class="row">
<div class="col-md-6 about-text">
<p >Yup</p>
</div>
</div>
</div>
</section>
You can use css vh property for this.
#header {
height: 100vh;
}
here is more info about css units. Hope this helps you.
change #header height to min-height:
#header {
min-height: 100%;
}
I have been trying to center my text over an image, however, it will not center. I have looked at various questions here on Stack Overflow, but none will work.
footer {
align-content: center;
justify-content: center;
}
.jumbotron {
display: flex;
align-items: center;
background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Wave_Panorama.jpg/1024px-Wave_Panorama.jpg');
background-size: cover;
color: #ffffff;
height: 500px;
text-shadow: 0.25px 0.25px 0.25px #000000;
}
.jumbotron h2 {
font-size: 60px;
font-weight: 700;
margin: 0;
color: #fff;
text-align: center;
position: absolute;
text-align: center;
margin: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<footer>
<section class="jumbotron">
<div class="container">
<div class="row text-center">
<h2>By Me</h2>
</div>
</div>
</section>
</footer>
I am quite new to HTML so if my code is messy/ confusing/ just plain wrong, that may be the reason. I was also trying to fix it with code snippets from Stack Overflow, so if some parts are unnecessary, please tell me so I can fix it.
Or, you know, just clean up the code a bit...
*removed the superflous <div>container, put flex: 1 1 0; where it should be, and removed some other non-sensical CSS as well.
.jumbotron {
display: flex;
text-align: center;
background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Wave_Panorama.jpg/1024px-Wave_Panorama.jpg');
background-size: cover;
color: #ffffff;
height: 500px;
text-shadow: 0.25px 0.25px 0.25px #000000;
}
.text-center {
flex: 1 1 0;
margin: auto;
}
.jumbotron h2 {
font-size: 60px;
font-weight: 700;
text-align: center;
}
<footer>
<section class="jumbotron">
<div class= "row text-center">
<h2>By Me</h2>
</div>
</section>
</footer>
Make position relative instead of absolute
footer {
align-content: center;
justify-content: center;
}
.jumbotron {
display: flex;
align-items: center;
background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Wave_Panorama.jpg/1024px-Wave_Panorama.jpg');
background-size: cover;
color: #ffffff;
height: 500px;
text-shadow: 0.25px 0.25px 0.25px #000000;
}
.jumbotron h2 {
font-size: 60px;
font-weight: 700;
margin: 0;
color: #fff;
text-align: center;
position: relative; /* MODIFICATION */
text-align: center;
margin: 0;
}
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<footer>
<section class="jumbotron">
<div class= "container">
<div class= "row text-center">
<h2> By Me</h2>
</div>
</div>
</section>
</footer>
I have been struggling to make right alignment and responsive. i want to add some of the test on top of the image. i have try changing values in css but it doesnt work out. i want to make as it below:
codepen: codepen link
Please advise. i am new to bootstrap.
<html>
<head>
<link data-require="bootstrap#4.0.0-alpha.2" data-semver="4.0.0-alpha.2" rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" />
<script data-require="bootstrap#4.0.0-alpha.2" data-semver="4.0.0-alpha.2" src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<div class="container-fluid" style="background: white;">
<div class="row no-gutter">
<div class="col-sm-3">
<div class="parent" >
<div class="circle">1</div>
<div class="expenseItems">Mobile</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent" >
<div class="circle">2</div>
<div class="expenseItems">Select a Product Category</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-4">
<div class="parent" >
<img src="http://images.clipartpanda.com/baby-blue-border-clipart-8748-light-blue-square-clip-art.png" class="tabimg" alt="">
<div class="circle tag" style="background-color:darkblue">3</div>
<div class="expenseItems">Find the latest software, firmware, and drivers<font color="darkblue"></font></div>
</div>
</div>
<div class="col-sm-2">
<div class="parent" >
<div class="circle">4</div>
<div class="expenseItems">Tablet Use</div>
<div class="hr"></div>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
.no-gutter > [class*='col-'] {
padding-right: 1px;
padding-left: 1px;
}
.parent {
border: 1px;
padding: 20px 25px 25px;
}
.circle {
width: 25px;
height: 25px;
border-radius: 50%;
padding-top: 3px;
display: inline-block;
text-align: center;
background-color: gray;
color: white;
}
.expenseItems {
padding: 10px;
display: inline-block;
color: gray;
font-size: 24px;
}
.hr {
background: gray;
height: 2px;
}
.tag {
float: left;
position: absolute;
left: 0px;
top: 15px;
z-index: 1000;
background-color: #92AD40;
padding: 5px;
color: #FFFFFF;
font-weight: bold;
}
.tabimg {
padding : 0px 0px 0px 0px;
height: 30px;
width: 100px;
margin-top: 0px;
}
The easiest approach to this would be just setting a background image to the div
in question.
I've added an ID to the div you're trying to add the image to, and I added the following code for that div.
#box-with-image {
background: url(http://images.clipartpanda.com/baby-blue-border-clipart-8748-light-blue-square-clip-art.png);
background-size: contain;
background-repeat: no-repeat;
/*
OTHER OPTION:
background-size: cover;
*/
}
Full Codepen Link
For sizing, contain will position the image top left, and fill whichever dimension is smallest. cover will fit whichever dimension is largest.
Or in other words, in a non-square shaped div, contain will leave whitespace, while cover will cut some of the image off.
Another approach to this would be using the following CSS on the image
img {
position: relative;
top: 0;
left: 0;
width: 100%;
}