I want to get result as shown in picture one but when I am coding it shows as I want by setting up margin left and right on images. It shows same result on some resolutions but not friendly in all resolution. I need a resolution friendly layout, please tell me how can i achieve this:
My code is
/* Slider */
.slider-bg {
background-image: url("http://www.design.earnandearn.com/zx-content/themes/default/media/img/grownstar-custom/slider_bg.jpg");
background-repeat: no-repeat;
background-size: cover;
border-bottom: 6px solid #E1B706;
height: 415px;
}
.container {
height: 415px;
max-width: 1030px;
margin: 0 auto;
}
.man {
height: 415px;
width: 542px;
background-image: url(http://www.design.earnandearn.com/zx-content/themes/default/media/img/grownstar-custom/man.png);
background-repeat: no-repeat;
position: absolute;
display: block;
right: 0;
}
.sliderright {
float: left;
height: 344px;
}
.sliderright h3 {
font-size: 39px;
color: #6e8d30;
margin-top: 60px;
}
.sliderright h2 {
color: #7b33ad;
font-size: 48px;
font-weight: 600;
}
.sliderright p {
font-size: 30px;
margin-top: 20px;
line-height: 1;
margin-bottom: 15px;
}
.sliderright a.btn {
background: none repeat scroll 0 0 #bae23d;
color: #000;
text-shadow: 0 1px 1px #000000;
font-size: 18px;
font-weight: 600;
margin-top: 15px;
margin-left: 0;
border: none;
width: 150px;
}
.sliderright small {
display: block;
}
<div class="slider-bg">
<div class="container">
<div class="sliderright">
<h3>Making Your Extra Money with</h3>
<h2>Our Social Network</h2>
<p>
<small>Achieve your dream for the financial freedom !</small>
Earn money Anywhere and Anytime
</p>
<a class="btn btn-warning" href="register.php">Signup Now !</a>
<div class="man"></div>
</div>
</div>
</div>
Just add top: 0; to your class ".man".
Like:
.man {
height: 415px;
width: 542px;
background-image: url(../img/grownstar-custom/man.png);
background-repeat: no-repeat;
position: absolute;
display: block;
right: 0;
top: 0,
}
Tipp: If you put the image with an <img> tag right into your .man div you don't need any height and width settings. The img will stretch it automatically.
And you should not name the class "man". Its not a man... Its a woman, I think.
Try this:-
<div class="slider-bg">
<div class="container">
<div class="sliderright">
<h3>Making Your Extra Money with</h3>
<h2>Our Social Network</h2>
<p>
<small>Achieve your dream for the financial freedom !</small>
Earn money Anywhere and Anytime
</p>
<a class="btn btn-warning" href="register.php">Signup Now !</a>
</div>
<div class="man" style="float:right;margin:-21px 6px 2px 9px;"></div>
</div>
</div>
Set your image manclass div out from the sliderrightclass div and give a margin to it.
See :- JSFiddle1
Update 1:-
Set propertyposition: relative; for both .container and .sliderright classes. See this updated code JSFiddle2.
Hope this will help you!
Related
I've set a blue background image, added some content and was done. I've tried zooming in the site, and whenever I zoom in, the background image automatically pushes itself up and does not cover the founders and half of the yellow arrow.
How it looks normally
How it looks when I zoom in
Any idea on how to fix this?
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
.container {
max-width: 900px;
margin: 0 auto;
}
.post-header {
background-color: #20cfcf;
background-image: url("../img2/header_background.png");
background-size: cover;
background-position: center center;
height: 60Vh;
text-align: center;
}
.post-header h2 {
text-align: center;
padding-top: 2em;
font-weight: 800;
font-size: 1.7em;
color: #172025
}
.post-header h1 {
font-size: 92pt;
font-weight: 900;
color: white;
margin: 0;
margin-top: em;
}
.founders {
margin-top: -6em;
}
.arrow-box {
position: relative;
background: url("https://i.imgur.com/gp3z7z5.png") no-repeat center center;
background-size: contain;
margin: auto;
width: 400px;
height: auto;
margin-top: -3em;
}
.arrow {
position: relative;
display: flex;
text-decoration: none;
align-items: center;
justify-content: center;
font-size:1.7rem;
height:80px;
color: black;
}
.dev-description {
font-size: 1.4em;
font-weight: 300;
line-height: 1.3em;
}
.recognize {
margin-top: 3em;
text-transform: uppercase;
font-weight: 700;
}
.images {
padding: 1em;
display: inline;
margin-top: 2em;
}
.images:hover,
.images:focus {
color: white;
}
.img-container {
margin-top: 1.3em;
}
<section class="post-header">
<div class="wrapper">
CHYBA TU
<h2>HI. WE'RE TILDE.</h2>
<h1>WE LIVE AND <br> BREATHE CODE.</h1>
<img src="img2/founders.png" class="founders" height="294px" width=425px alt="">
<div class="arrow-box">
Meet the team
</div>
<div class="container">
<p class="dev-description">
We're a small team of developers who are passionate about crafting great software.
We're some of the faces behind Ember.js, Ruby on Rails, jQuery and more. <br>
We're here to help you build the products and tools of the future.
</p>
<p class="recognize">
you may recognize us from around town
</p>
<div class="img-container">
<div class="images">
<img src="img2/rails.png" alt="">
</div>
<div class="images">
<img src="img2/jquery.png" alt="">
</div>
<div class="images">
<img src="img2/ember.png" alt="">
</div>
<div class="images">
<img src="img2/handlebars.png" alt="">
</div>
<div class="images"></div>
<img src="img2/bundler.png" alt="">
</div>
</div>
</div>
</div>
</section>
Thanks in advance. Let me know if something is unclear.
I think you can do like this.
.post-header {
background-color: #20cfcf;
background-image:
url("../img2/header_background.png");
background-size: cover;
background-position: center center;
height: 582px;
text-align: center;
}
An alternate solution is to adjust the markup of your hero so that the people and arrow images are positioned at the bottom of the background, this means it will work on mobile/desktop and all heights, widths and zoom levels.
In this solution, we create a .hero container and place everything that is meant to be in front of the blue background inside of it. We position the images absolutely, from the bottom, transforming the arrow down 50%.
If you run into issues with the hard-coded height from the other answer then this will work for you.
.hero {
background-color: #20cfcf;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 100px 0 200px;
position: relative;
text-align: center;
}
.preheading {
font-size: 1.7em;
font-weight: 800;
text-transform: uppercase;
}
.heading {
color: #fff;
font-size: 92pt;
font-weight: 900;
text-transform: uppercase;
}
.people {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
.arrow {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 50%);
}
img {
border: 1px solid black;
}
<div class="hero">
<div class="preheading">Hi. We're Tilde.</div>
<div class="heading">We live and<br>breate code.</div>
<img class="people" src="https://via.placeholder.com/400x300">
<img class="arrow" src="https://via.placeholder.com/200x80">
</div>
I am making website in html and css and I have a problem. In my css file I made id "full" which set wooden background after sidebar and it should continue on all page. In my class "picture" I made 80% width white panel - so there should be 80% white background in the middle and 10% edges should be wooden. It works correctly untill my article section, where I added some images of pizzeria. Immediately there is no wooden edges, only white. I don´t understand because my "full" id and "picture" class continue untill end of the body. Could somebody see where is error please?
Image showing error
* {
padding: 0;
margin: 0;
border: 0;
}
.container {
margin: auto;
overflow: hidden;
width: 100%;
}
#full {
background-image: url("http://newallpaper.com/wp-content/uploads/2014/01/Dark-Wood-620x387.jpg");
}
.picture {
margin: auto;
width: 80%;
background: white;
}
#pizzaObrazok {
background-image: url("img/pizzaCompleted.png");
width: 100%;
height: 210px;
margin: 0px;
}
nav {
float: left;
margin-left: 2px;
width: 100%;
height: 32px;
}
ul {
float: left
}
li {
display: inline;
border: 4px solid black;
font-size: 24px;
padding: 10px 64px;
background-color: #990000;
color: #ffffff;
}
li a {
color: #ffffff;
text-decoration: none;
padding-top: 8px;
padding-bottom: 5px;
vertical-align: middle;
}
#imgPizza {
width: 59%;
height: 270px;
padding-left: 190px;
padding-top: 30px;
padding-bottom: 30px;
}
article p {
font-size: 120%;
font-family: fantasy;
text-align: center;
margin-right: 160px;
}
#imgPizza2 {
width: 30%;
height: 270px;
position: absolute;
transform: rotate(345deg);
margin-top: 100px;
margin-left: 50px;
border: 6px solid red;
}
#imgPizza3 {
width: 30%;
height: 270px;
position: absolute;
margin-left: 390px;
margin-top: 100px;
transform: rotate(15deg);
border: 6px solid red;
}
#phone {
border: 2px solid black;
margin-top: 150px;
margin-right: 180px;
padding: 5px;
position: absolute;
display: inline;
text-align: center;
background: #ff4d4d;
}
<header>
<div id="pizzaObrazok">
</div>
</header>
<div id="full">
<section id="navigation">
<div class="container">
<nav>
<ul>
<li>ÚVOD</li>
<li>FOTO</li>
<li>JEDÁLNY LÍSTOK</li>
<li>KDE NÁS NÁJDETE</li>
<li>NÁZORY</li>
</ul>
</nav>
</div>
 
</section>
<div class="picture">
<img id="imgPizza" src="img/pizzacheese.jpg">
<aside id="phone">
<h2>Telefónne číslo:</h2>
<h2> 0905 741 963</h2>
</aside>
</div>
 
<div class="picture">
<article>
<p>U nás dostanete najchutnejšiu pizzu z výlučne kvalitných surovín</p>
<img id="imgPizza2" src="https://cdn.vox-cdn.com/uploads/chorus_image/image/50289897/pizzeria_otto.0.0.jpg">
<img id="imgPizza3" src="https://media-cdn.tripadvisor.com/media/photo-s/09/bc/74/79/pizzeria-du-drugstore.jpg">
</article>
</div>
</div>
You have your elements "#imgPizza2" and "#imgPizza3" whit position absolute outside your "#full" wrapper. You can do various things to achive the effect you are looking for but depends of many others things.
I think the simpliest way is to put your background image in to the body and not in the warpper "#full" or change the postion of your images among others.
body {
background-image: url("http://newallpaper.com/wp-content/uploads/2014/01/Dark-Wood-620x387.jpg");
}
It looks like the wood background is 620 x 387, so my first thought is that it is big enough to cover the first section but not the articles. Maybe add background-repeat: repeat-y; to your #full class and see if the wood border spreads further down the page.
I am making a website and I need a CTA image.
I am using Bootstrap 4 and I have made a custom CSS to adjust how the image will look. I've put it so that it takes up the whole width of the screen, so width: 100%;
When I adjust the size of the screen, the image is responsive and also adjusts itself so that it will turn smaller and fit the whole screen. But when is on a regular big sized screen the image takes up the whole website so I want to be able to leave it as 100% width but with a smaller height. When I try adjusting the max-height it just ends up stretching the image and it is not appealing to look at. What should I do?
This is the HTML Section:
<!-- CTA Section -->
<div class="img-wrapper">
<img class="img-responsive" src="I/CTA.png">
<div class="img-overlay">
Want to see what more we have to offer?
<br><br>
<a href="coffee.html"><button class="btn btn-md btn-primary">
Click here</button></a>
</div>
</div>
<!-- /.img-wrapper -->
This is the CSS section of the code:
.img-wrapper {
position: relative;
}
.img-wrapper img {
width: 100%;
max-height: 650px;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
color: white;
font-size: 14px;
}
.img-overlay:before {
content: ' ';
display: block;
height: 60%;
}
button {
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
}
.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;
}
}
You can use object-fit, though it hasn't so good browser support yet, so a solution making use of background-image might be needed (based on the browser support you require)
Here is a solution using object-fit
.img-wrapper img {
width: 100%;
max-height: 350px;
object-fit: cover;
}
Fiddle demo
Stack snippet
.img-wrapper {
position: relative;
}
.img-wrapper img {
width: 100%;
max-height: 350px;
object-fit: cover;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
color: white;
font-size: 14px;
}
.img-overlay:before {
content: ' ';
display: block;
height: 60%;
}
button {
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
}
.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;
}
}
<!-- CTA Section -->
<div class="img-wrapper">
<img class="img-responsive" src="http://lorempixel.com/500/350/nature/1/">
<div class="img-overlay">
Want to see what more we have to offer?
<br><br>
<a href="coffee.html"><button class="btn btn-md btn-primary">
Click here</button></a>
</div>
</div>
Here is another using background-image.
The trick for making this work, is to keep the image in place, but with visiblity: hidden set. This will make the image wrapper size proper, and then the background image adjust without stretching.
Fiddle demo
Stack snippet
.img-wrapper {
position: relative;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.img-wrapper img {
width: 100%;
max-height: 350px;
visibility: hidden;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
color: white;
font-size: 14px;
}
.img-overlay:before {
content: ' ';
display: block;
height: 60%;
}
button {
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
}
.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;
}
}
<!-- CTA Section -->
<div class="img-wrapper" style="background-image: url(http://lorempixel.com/500/350/nature/1/)">
<img class="img-responsive" src="http://lorempixel.com/500/350/nature/1/">
<div class="img-overlay">
Want to see what more we have to offer?
<br>
<br>
<a href="coffee.html">
<button class="btn btn-md btn-primary">
Click here</button>
</a>
</div>
</div>
I just finished developing my first web page using flexbox. It looks great on my screen resolution (1326x768) but when I test it on a larger screen (1894x787), the content looks crazy stretched. Below are the screen shots:
At 1326x768
At higher screen resolution
Codepen
I had used flex: 1 1 60% on some elements (the % varies of course), but making flex-grow: 0 doesn't really do anything.
I have only set fixed parameters for the containers of images (fixed heights). I haven't set fixed widths for any container.
Am I missing something with flex boxes here?
I guess media queries might be one way to solve this problem but is there any other solution, a more robust way to develop using flex?
How can I make the page look the way it is meant to in all screen sizes not stretched or overly compressed?
html,
body {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
* {
box-sizing: border-box;
}
p {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
.margin-end {
margin-bottom: 40px;
}
.margin-start {
margin-top: 10px;
}
header {
display: flex;
flex-direction: row;
justify-content: space-between;
color: #6e6e6e;
font-family: AvenirLTStd-Roman;
font-weight: bolder;
font-size: 1rem;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.11);
/*box-shadow: 0px 10px 5px -9px rgba(0,0,0,0.75);*/
/*border-bottom: solid 1px #ececec;*/
}
.banner-heading {
margin-left: 350px;
font-weight: bolder;
font-size: 1.875rem;
}
.secondary-heading {
/* border: solid;
*/
display: flex;
flex-direction: row;
margin-right: 60px;
font-size: 0.8rem;
justify-content: center;
position: relative;
/* margin: auto;
*/
}
.secondary-heading-1 {
padding-right: 60px;
/* vertical centering */
position: relative;
top: 50%;
transform: translateY(-50%);
font-weight: lighter;
}
.secondary-heading-2 {
/* vertical centering */
position: relative;
top: 50%;
transform: translateY(-50%);
color: #6e6e6e;
font-weight: lighter;
}
.secondary-heading-1 a,
.secondary-heading-2 a {
color: #6e6e6e;
}
.main-content {
display: flex;
flex-direction: row;
/* border:solid;
*/
margin-left: 350px;
margin-right: 60px;
}
.main-content-left {
/* border:dashed;*/
/*width: 200px;
height: 200px;*/
display: flex;
flex-direction: column;
flex: 0 1 60%;
padding-right: 20px;
}
.main-content-left-heading {
width: 100%;
border-bottom: solid 1px #959595;
padding-bottom: 20px;
padding-top: 20px;
}
.main-content-right {
/*border: dashed;*/
/*width: 200px;
height: 200px;*/
margin-left: auto;
flex: 0 1 40%;
}
.main-content-left-heading p {
/*margin:0;
padding:0;*/
line-height: 100%;
}
.main-content-left-heading-1 {
font-family: AvenirLTStd-Roman;
font-style: italic;
color: #6e6e6e;
}
.main-content-left-heading-2 {
padding-top: 5px;
font-family: AvenirLTStd-Roman;
color: #6e6e6e;
font-weight: bolder;
font-size: 1.5rem
}
.main-content-left-image-1 {
padding: 0;
margin: 0;
/* border: solid;
*/
width: 100%;
height: 360px;
background-image: url("https://gallery.mailchimp.com/f68128197412f5658c731b840/images/010fa5bb-20b9-4603-8e31-3a5e053d936f.png");
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
}
.main-content-left-image-2 {
padding: 0;
margin: 0;
/* border: solid;
*/
width: 100%;
height: 360px;
background-image: url("https://gallery.mailchimp.com/f68128197412f5658c731b840/images/a49ee715-cd02-4b16-9164-941585e2fbbe.png");
background-size: 100% 100%;
background-repeat: no-repeat;
}
.main-content-left-image-3 {
padding: 0;
margin: 0;
/* border: solid;
*/
width: 100%;
height: 360px;
background-image: url("https://gallery.mailchimp.com/f68128197412f5658c731b840/images/2b74f1ec-1a17-4c84-b162-ff62437cd705.png");
background-size: 100% 100%;
background-repeat: no-repeat;
}
.main-content-left-text {
/* border:solid;
*/
display: flex;
flex-direction: row;
margin-top: solid;
padding-top: 20px;
/* padding-bottom: 20px;
*/
}
.main-content-left-text-group-left {
padding: 10px 60px 10px 0px;
}
.main-content-left-text-group-left-1 {
padding-bottom: 10px;
font-family: SourceSansBold;
font-size: 0.875rem;
font-weight: 900;
}
.main-content-left-text-group-left-2 {
font-family: SourceSansBold;
font-size: 0.875rem;
color: #888585;
font-weight: 900;
}
.main-content-left-text-group-right {
padding: 10px;
border-left: solid 1px #959595;
}
.main-content-left-text-group-right-1 {
font-family: Avenir-Next-LT-Pro-Demi;
font-size: 1.45rem;
padding-bottom: 20px;
color: #444444;
font-weight: bolder;
}
.main-content-left-text-group-right-2 {
font-size: 1rem;
font-family: SourceSansPro-Regular;
}
.main-content-right {
border-left: solid 1px #959595;
margin-top: 20px;
padding-right: 65px;
padding-left: 20px;
display: flex;
flex-direction: column;
}
.main-content-right-heading {
border-bottom: solid 2px #363636;
height: 65px;
display: flex;
}
.main-content-right-heading p {
font-size: 0.9rem;
margin-top: auto;
font-family: SourceSansBolder;
font-weight: bolder
}
.main-content-right-content {
padding-top: 10px;
padding-bottom: 10px;
border-bottom: solid 1px #959595;
}
.main-content-right-image-1 {
width: 100%;
height: 180px;
background: url("https://gallery.mailchimp.com/f68128197412f5658c731b840/images/2b74f1ec-1a17-4c84-b162-ff62437cd705.png") no-repeat;
background-size: 100% 100%;
}
.main-content-right-image-2 {
width: 100%;
height: 180px;
background: url("https://gallery.mailchimp.com/f68128197412f5658c731b840/images/2b74f1ec-1a17-4c84-b162-ff62437cd705.png") no-repeat;
background-size: 100% 100%;
}
.main-content-right-image-3 {
width: 100%;
height: 180px;
background: url("https://gallery.mailchimp.com/f68128197412f5658c731b840/images/2b74f1ec-1a17-4c84-b162-ff62437cd705.png") no-repeat;
background-size: 100% 100%;
}
.main-content-right-group {
/*border:solid;*/
/* padding-bottom: 10px;
*/
}
.main-content-right-group-1 {
padding-top: 10px;
color: #b8b6b6;
font-family: SourceSansBold;
font-size: 0.875rem
}
.main-content-right-group-2 {
padding-top: 10px;
font-family: Avenir-Next-LT-Pro-Demi;
font-weight: bolder;
color: #444444;
font-size: 1.1rem;
}
<header>
<h1 class="banner-heading">Entrepreneurs Weekly</h1>
<div class="secondary-heading">
<h3 class="secondary-heading-1">BECOME A CURATOR</h3>
<h3 class="secondary-heading-2">ABOUT</h3>
</div>
</header>
<div class="main-content">
<div class="main-content-left">
<div class="main-content-left-heading">
<p class="main-content-left-heading-1">Week 008,</p>
<p class="main-content-left-heading-2">How To create the next Steve Jobs</p>
</div>
<div class="main-content-left-heading">
<div class="main-content-left-image-1">
<!-- <img src="assets/WeeklyContent1.png" />
-->
</div>
<div class="main-content-left-text">
<div class="main-content-left-text-group-left">
<p class="main-content-left-text-group-left-1">POLITICS</p>
<p class="main-content-left-text-group-left-2">NYTIMES.COM</p>
</div>
<div class="main-content-left-text-group-right">
<p class="main-content-left-text-group-right-1">New York magazine turns a history of shopping recommendations into a new online revenue stream</p>
<p class="main-content-left-text-group-right-2">Making money from $195 fitted sheets and Japanese women’s facial razors.</p>
</div>
</div>
</div>
<div class="main-content-left-heading">
<div class="main-content-left-image-2">
<!-- <img src="assets/WeeklyContent1.png" />
-->
</div>
<div class="main-content-left-text">
<div class="main-content-left-text-group-left">
<p class="main-content-left-text-group-left-1">POLITICS</p>
<p class="main-content-left-text-group-left-2">NYTIMES.COM</p>
</div>
<div class="main-content-left-text-group-right">
<p class="main-content-left-text-group-right-1">The Texas Tribune updates its premium political coverage for an email</p>
<p class="main-content-left-text-group-right-2">Making money from $195 fitted sheets and Japanese women’s facial razors.</p>
</div>
</div>
</div>
<div class="main-content-left-heading margin-end">
<div class="main-content-left-image-3">
<!-- <img src="assets/WeeklyContent1.png" />
-->
</div>
<div class="main-content-left-text">
<div class="main-content-left-text-group-left">
<p class="main-content-left-text-group-left-1">POLITICS</p>
<p class="main-content-left-text-group-left-2">NYTIMES.COM</p>
</div>
<div class="main-content-left-text-group-right">
<p class="main-content-left-text-group-right-1">The Incline, Billy Penn’s new sister site, launches in Pittsburgh</p>
<p class="main-content-left-text-group-right-2">Like Billy Penn in Philadelphia, the Pittsburgh site will focus on attracting a younger audience through events and aggregation in addition to original reporting.</p>
</div>
</div>
</div>
</div>
<div class="main-content-right">
<div class="main-content-right-heading">
<p>THE LATEST FROM ENTREPRENEUR'S WEEKLY</p>
</div>
<div class="main-content-right-content margin-start">
<div class="main-content-right-image-1">
<!-- image goes as background -->
</div>
<div class="main-content-right-group">
<p class="main-content-right-group-1">WEEK 01</p>
<p class="main-content-right-group-2">New York magazine turns a history of shopping recommendations into a new online revenue stream</p>
</div>
</div>
<div class="main-content-right-content">
<div class="main-content-right-image-2">
<!-- image goes as background -->
</div>
<div class="main-content-right-group">
<p class="main-content-right-group-1">WEEK 01</p>
<p class="main-content-right-group-2">New York magazine turns a history of shopping recommendations into a new online revenue stream</p>
</div>
</div>
<div class="main-content-right-content">
<div class="main-content-right-image-3">
<!-- image goes as background -->
</div>
<div class="main-content-right-group">
<p class="main-content-right-group-1">WEEK 01</p>
<p class="main-content-right-group-2">New York magazine turns a history of shopping recommendations into a new online revenue stream</p>
</div>
</div>
</div>
</div>
This is the source of your problem:
.main-content-left-image-1 {
padding: 0;
margin: 0;
width: 100%; <---- problem
height: 360px; <---- problem
background-image: url("https://gallery.mailchimp.com/f6...");
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
}
.main-content-left-image-2 {
padding: 0;
margin: 0;
width: 100%; <---- problem
height: 360px; <---- problem
background-image: url("https://gallery.mailchimp.com/f6...");
background-size: 100% 100%;
background-repeat: no-repeat;
}
If you tell an image to be width: 100% and height: 360px, consider how that plays out.
The width is always the full length of the container. Whether the screen is wide or narrow, the image goes with it.
But you have set a fixed height of 360px. There's no flexibility there.
As a result, the image is flexible horizontally and inflexible vertically, which leads to a loss of aspect ratio / distortion.
There are several possible solutions to this problem:
Responsive css background images
How to make CSS background-image responsive?
Since a few days I am trying to make this work. I have a design with an image with a text over it, I just finally could set the text over the image, but I want to give a top position to the image but too much space at the bottom and I don't know how to fix it!
This is what I have: I know I have to fix some padding things on the texts.
and this is my markup, by the way I am using bootstrap.
<div class="row-color clearfix">
<div class="container">
<div class="col-lg-12 no-padding wrapper">
<img class="img-responsive" src="http://s12.postimg.org/mu9u7nzvx/header_ml_02.png" alt="">
<div id="bg-text">
<div class="text-overimg">Child Education Planner</div>
</div>
</div>
<div class="texto_cursos">Face courses, distance and on-line</div>
</div>
</div>
.row-color {
background: #575756 none repeat scroll 0 0;
color: #fff;
font-size: 18px;
line-height: 1.5em;
position: relative;
z-index: 9;
padding-bottom: 20px;
}
.no-padding {
padding:0px;
}
.wrapper {
padding-left: 10px;
padding-right: 10px;
text-align:center;
position:relative;
}
.wrapper .img-responsive {
display:inline;
}
.wrapper #bg-text {
color: white;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
text-align:center;
padding-left:10px;
padding-right:10px;
}
.text-overimg{
position:relative;
font-size:3.1em;
color:#FFF;
font-weight:500;
text-shadow: 0.08em 0.08em 0.05em #333;
padding-top: 20%;
}
.texto_cursos{
padding-bottom: 10px;
font-size:2.5em;
color:#FFF;
font-weight:400;
text-align:center;
}
I would like to have this, I have to say that I want to make it responsive for most of the devices, this is one of the things I use bootstrap.
This is what I really want to have but don't know how to do it. Specially the white background behind the image without too much space between the last text and the image.
Thanks again!
** UPDATE I Accidently said if you want to move the image up a little. I meant down**
If you want to move the image down a little you can add a margin-top to it:
.wrapper .img-responsive {
display:inline;
margin-top:50px;
}
Please see JSFiddle here
try something like that:
.imagebox-container {
width: 100%;
padding-top: 30px;
background: linear-gradient(0, gray 50%, transparent 50%);
}
.imagebox img {
max-width: 100%;
display: block;
}
.imagebox-caption {
width: 100%;
text-align: center;
padding: 5px;
line-height: 1;
}
.imagebox {
position: relative;
width: 400px;
margin: 0 auto;
}
.imagebox-caption-overlay {
position: absolute;
bottom: 10px;
transition: 500ms all linear;
width: 100%;
text-align: center;
background: transparent;
color: white;
}
.imagebox:hover .imagebox-caption-overlay {
background: white;
color: black;
}
<div class="imagebox-container">
<div class="imagebox">
<img src="https://www.drupal.org/files/issues/header_1.png" />
<div class="imagebox-caption-overlay">ANOTHER BLA BLA BLA</div>
</div>
<div class="imagebox-caption">
bla bla bla
</div>
</div>
may be you need this. please see .
.imagebox-container {
width: 100%;
padding-top: 30px;
background: linear-gradient(0, gray 50%, transparent 50%);
}
.imagebox img {
max-width: 100%;
width: 400px;
margin: 0 auto;
display: block;
}
.imagebox-caption {
width: 100%;
text-align: center;
padding: 5px;
line-height: 1;
}
<div class="imagebox-container">
<div class="imagebox">
<img class="img-responsive" src="http://s12.postimg.org/mu9u7nzvx/header_ml_02.png" alt="">
</div>
<div class="imagebox-caption">
Face courses, distance and on-line
</div>
</div>