Div background-image isn't showing - html

I wanted to put a background image inside the div "pageIntro". I've tried setting the background color to transparent, checked the image file path numerous times (it is certainly correct as when I click it in my code using vsCode it pops the correct image).
Note: putting a background color works fine
screensnip of the div with NO background color. Background-image is set to '/img/home/flower-cup.jpg'.
screensnip of the div with GOLD background color. Background-image is still set to '/img/home/flower-cup.jpg'.
Here's the CSS of the div and all the elements inside it:
div.pageIntro {
position: relative;
background-image: url('/img/home/flower-cup.jpg') ;
background-repeat: no-repeat;
background-size: cover;
max-width: 100%;
width: 100vw;
height: 100vh;
z-index: 001;
text-align: center;
}
.introDiv {
background-color: black;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 002;
}
.introText {
font-weight: bold;
font-family: "eczar";
color: whitesmoke;
font-size: 50px;
z-index: 002;
}
.subIntroButton {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color:rgba(0, 0, 0, 0.1);
width: 150px;
border-style: solid;
border-radius: 5%;
border-color: whitesmoke;
border-width: 2px;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
color: whitesmoke;
padding: 10px 10px;
}
Here's the HTML:
<div class='pageIntro'>
<div class="introDiv">
<p class='introText'> You deserve it. </p>
<a href="menu.html" style="text-decoration : none">
<div class='subIntroButton'> check treats </div>
</a>
</div>
<span class="blinking" href="javascript:"><img src="img/arrow-down.png" style="position: relative; bottom: 12%; width: 40px"></span></div>
</div>
Thank you very much :)
UPDATE:
Here's what it looks like when putting the background-image on BOTH inner and outer div. Unfortunately, it only works on the inner.

Issue is with your Image Relative Path i just tried you code with an online image path its working fine.
div.pageIntro {
position: relative;
background-image: url('https://images.pexels.com/photos/531880/pexels-photo-531880.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500') ;
background-repeat: no-repeat;
background-size: cover;
max-width: 100%;
width: 100vw;
height: 100vh;
z-index: 001;
text-align: center;
}
.introDiv {
background-color: black;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 002;
}
.introText {
font-weight: bold;
font-family: "eczar";
color: whitesmoke;
font-size: 50px;
z-index: 002;
}
.subIntroButton {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color:rgba(0, 0, 0, 0.1);
width: 150px;
border-style: solid;
border-radius: 5%;
border-color: whitesmoke;
border-width: 2px;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
color: whitesmoke;
padding: 10px 10px;
}
<div class='pageIntro'>
<div class="introDiv">
<p class='introText'> You deserve it. </p>
<a href="menu.html" style="text-decoration : none">
<div class='subIntroButton'> check treats </div>
</a>
</div>
<span class="blinking" href="javascript:"><img src="img/arrow-down.png" style="position: relative; bottom: 12%; width: 40px"></span></div>
</div>

Hi As I can see your relative path.
if the image forlder is in same path of your html
What i can see error in your HTML. Which is span is not properly closed with a and img tag.
<div class='pageIntro'>
<div class="introDiv">
<p class='introText'> You deserve it. </p>
<a href="menu.html" style="text-decoration : none">
<div class='subIntroButton'> check treats </div>
</a>
</div>
<span class="blinking" href="javascript:"><img src="img/arrow-down.png" style="position: relative; bottom: 12%; width: 40px"/></span>
</div>
you can use .
div.pageIntro {
position: relative;
background-image: url('./img/home/flower-cup.jpg') ;
background-repeat: no-repeat;
background-size: cover;
max-width: 100%;
width: 100vw;
height: 100vh;
z-index: 001;
text-align: center;
}
Or if its one above your path you can use ..
div.pageIntro {
position: relative;
background-image: url('../img/home/flower-cup.jpg') ;
background-repeat: no-repeat;
background-size: cover;
max-width: 100%;
width: 100vw;
height: 100vh;
z-index: 001;
text-align: center;
}
I have created one JS fiddle

Related

I am trying to make 4 stylised cards in html with different positions that display info but they are not formatting correctly

I'm trying to make this in HTML/CSS
Image design in Figma of what I am trying to make
And currently It looks like this
Current way it looks
I am not sure why it is formatting like that and to clarify I haven't made the other 2 cards yet because I was trying to get the first 2 right.
Here is the HTMl code for it (don't mind the class names please)
<div class="v10_8">
<div class="v10_9"></div>
<div class="v10_15">
<div class="v10_14"><span class="v10_10">CAREY</span><span class="v10_11">1</span></div>
<span class="v10_12">On 56 Points</span>
</div>
</div>
<div class="v10_16">
<div class="v10_17"></div>
<div class="v10_18">
<div class="v10_19"><span class="v10_20">STANWAY</span><span class="v10_21">2</span></div>
<div class="v10_40"><span class="v10_22">On 40 Points</span><span class="v10_39">16 points behind Carey</span></div>
</div>
</div>
</div>
And here is the CSS code for it:
width: 262px;
height: 617px;
background: url("../images/v10_23.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 65px;
opacity: 1;
position: relative;
top: 0px;
left: 0px;
overflow: hidden;
}
.v10_8 {
width: 262px;
height: 276px;
background: rgba(255,255,255,1);
opacity: 1;
position: relative;
top: 0px;
left: 0px;
border-top-left-radius: 44px;
border-top-right-radius: 44px;
border-bottom-left-radius: 44px;
border-bottom-right-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
}
.v10_9 {
width: 267px;
height: 96px;
background: rgba(248,228,125,1);
opacity: 1;
position: absolute;
top: 180px;
left: 0px;
overflow: hidden;
}
.v10_15 {
width: 135px;
height: 210px;
background: url("../images/v10_15.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 44px;
opacity: 1;
position: absolute;
top: 29px;
left: 65px;
overflow: hidden;
}
.v10_14 {
width: 94px;
height: 138px;
background: url("../images/v10_14.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 17px;
opacity: 1;
position: absolute;
top: 0px;
left: 21px;
overflow: hidden;
}
.v10_10 {
width: 94px;
color: rgba(21,21,21,1);
position: relative;
top: 0px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 29px;
opacity: 1;
text-align: left;
}
.v10_11 {
width: 30px;
color: rgba(21,21,21,1);
position: absolute;
top: 52px;
left: 32px;
font-family: Folito;
font-weight: Bold;
font-size: 71px;
opacity: 1;
text-align: left;
}
.v10_12 {
width: 135px;
color: rgba(21,21,21,1);
position: absolute;
top: 183px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 22px;
opacity: 1;
text-align: left;
}
.v10_16 {
width: 262px;
height: 276px;
background: rgba(255,255,255,1);
opacity: 1;
position: absolute;
top: 341px;
left: 1px;
border-top-left-radius: 44px;
border-top-right-radius: 44px;
border-bottom-left-radius: 44px;
border-bottom-right-radius: 44px;
box-shadow: -10.746728897094727px 9.849809646606445px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
}
.v10_17 {
width: 267px;
height: 96px;
background: rgba(119,221,119,1);
opacity: 1;
position: absolute;
top: 180px;
left: 0px;
overflow: hidden;
}
.v10_18 {
width: 167px;
height: 241px;
background: url("../images/v10_18.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 44px;
opacity: 1;
position: absolute;
top: 16px;
left: 50px;
overflow: hidden;
}
.v10_19 {
width: 135px;
height: 138px;
background: url("../images/v10_19.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 17px;
opacity: 1;
position: absolute;
top: 0px;
left: 16px;
overflow: hidden;
}
.v10_20 {
width: 135px;
color: rgba(21,21,21,1);
position: absolute;
top: 0px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 29px;
opacity: 1;
text-align: left;
}
.v10_21 {
width: 42px;
color: rgba(21,21,21,1);
position: absolute;
top: 52px;
left: 46px;
font-family: Folito;
font-weight: Bold;
font-size: 71px;
opacity: 1;
text-align: left;
}
.v10_40 {
width: 167px;
height: 57px;
background: url("../images/v10_40.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 11px;
opacity: 1;
position: absolute;
top: 183px;
left: 0px;
overflow: hidden;
}
.v10_22 {
width: 137px;
color: rgba(21,21,21,1);
position: absolute;
top: 0px;
left: 15px;
font-family: Folito;
font-weight: Medium;
font-size: 22px;
opacity: 1;
text-align: left;
}
.v10_39 {
width: 167px;
color: rgba(21,21,21,1);
position: absolute;
top: 38px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 16px;
opacity: 1;
text-align: left;
}
I understand the design may look slightly hard to code but I will try.
I would appreciate it if someone can help me thanks.
Two problems here...
FIRST ONE: The first code of the css you provided is incomplete.
FIRST ONE:
As I looked through your code, I realised you interchanged the positioning of the elements. Use the absolute position on the parent element and relative on the contents of the parent element. If you are a bit confused about the second issue, kindly correct the first mistake and prompt me. I'll help you out.
For this design, you must have a box that contains three columns and have two contents in the left column and the contents in the other columns are in the center.
You can achieve this in minimum div this is example for your single card you can make further changes in it.
.box1_1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 262px;
height: 276px;
background: gray;
opacity: 1;
border-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
position: relative;
}
.box1_3 {
padding-top: 20%;
font-size: 25px;
font-weight: bold;
text-align: center;
background: red;
height: 100%;
width: 100%;
position: absolute;
top: 10;
}
.box1_2{
font-size: 25px;
font-weight: bold;
text-align: center;
background: yellow;
height: 35%;
width: 100%;
position: absolute;
bottom: 0%;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869); /* Add the same box-shadow as the parent container */
}
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<p>1</p>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>

css - How to center multiple divs without overlapping?

I want to enter a title, a line and a subtitle in the center of an image (horizontally and vertically), in this order from top to bottom, with the line between the two texts, but they keep overlapping. I've tried some answers from other questions, such as changing from div to span and setting display:block in the outter div and display:inline-block in the inner divs, for example, but nothing works.
With flexbox, I ran into the issue of needing to name all of their classes the same for it to work, which is not viable because they have different properties.
Appreciate the help!
Here's the code and the fiddle:
https://jsfiddle.net/u8asjmy7/
HTML
<div class="banner">
<div class="titulo-banner"><b>BIG TITLE</b></div>
<div class="linha-banner"></div>
<div class="texto-banner"><b>Small<br>subtitle.</b></div>
</div>
CSS
body, html {
height: 100%;
margin: 0;
}
.banner {
background-image: linear-gradient(to bottom, rgba(245, 246, 252, 0.1), rgba(20, 20, 20, 0.90)), url('../images/cp/brian-lundquist.png');
object-fit: cover;
height: 100%;
width: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
text-align: center;
color: white;
}
.titulo-banner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: Martel;
font-size: calc(15px + 2vw);
}
.linha-banner {
height: 4px;
width: 15vw;
background: #ffc700;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.texto-banner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: Martel;
font-size: calc(15px + 0.5vw);
}
Hmm, I think you could still use flexbox without having to name all the existing classes, does this accomplish what you need?
body,
html {
height: 100%;
margin: 0;
}
.banner {
background-image: linear-gradient(to bottom, rgba(245, 246, 252, 0.1), rgba(20, 20, 20, 0.90)), url('../images/cp/brian-lundquist.png');
object-fit: cover;
height: 100%;
width: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
text-align: center;
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.titulo-banner {
font-family: Martel;
font-size: calc(15px + 2vw);
}
.linha-banner {
height: 4px;
width: 15vw;
background: #ffc700;
}
.texto-banner {
font-family: Martel;
font-size: calc(15px + 0.5vw);
}
<div class="banner">
<div class="titulo-banner"><b>BIG TITLE</b></div>
<div class="linha-banner"></div>
<div class="texto-banner"><b>Small<br>subtitle.</b></div>
</div>
If you must use position: absolute, you should do it only on the container of those texts. Let me know if you need a better solution

Image (location pins) on top of background image

i have location pins on top of background image.
but when its responsive pins location chages.
i want set pins at specific position of images
<div class="container">
<img src="http://www.clipartbest.com/cliparts/ncX/qyL/ncXqyLdcB.png" class="pin1">
<img src="http://www.clipartbest.com/cliparts/ncX/qyL/ncXqyLdcB.png" class="pin2">
</div>
css
body {
background: url(http://connect.homes.com/wp-content/uploads/2012/05/200392710-0012.jpg) no-repeat center center fixed;
/* -webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;*/
color: white;
font-family: 'Open Sans', 'Nunito', sans-serif;
}
.pin1 {
position: absolute;
width: 30px;
height: auto;
top: 10%;
left: 28%;
}
.pin2 {
position: absolute;
width: 30px;
height: auto;
top: 40%;
left: 50%;
}
i am trying to set position but its not working
Don't use a background image as it's not responsive in the same way as positioning. Use an actual inline image in a wrapper and position your pins on that.
Here's an example:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-align: center;
}
.map {
margin: 10px;
border: 5px solid red;
position: relative;
display: inline-block;
}
.map img {
max-width: 100%;
display: block;
}
.box {
width: 8%;
height: 8%;
background-image: url(http://www.clker.com/cliparts/W/0/g/a/W/E/map-pin-red.svg);
background-position: top center;
background-repeat: no-repeat;
background-size: contain;
position: absolute;
}
#pin-1 {
top: 29%;
left: 36%;
}
.box:hover>.pin-text {
display: block;
}
.pin-text {
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 75%;
white-space: nowrap;
display: none;
}
.pin-text h3 {
color: white;
text-shadow: 1px 1px 1px #000;
}
<div class="map">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Pleasant_View_housing_development%2C_Missoula%2C_Montana_-_panoramio.jpg/800px-Pleasant_View_housing_development%2C_Missoula%2C_Montana_-_panoramio.jpg" alt="" />
<div id="pin-1" class="box">
<div class="pin-text">
<h3>My House</h3>
</div>
</div>
</div>

Why is my FontAwesome content appearing off center as a background?

I am trying to set a FontAwesome icon as a "defualt thumbnail" for a list of articles. My problem is that the icon is appearing off center horizontally in my div. See the jsFiddle.
<div class="card-row-image fa fa-cutlery thumbnail-default">
<div class="card-row-label">Restaurants
</div>
<div class="card-row-price">Pennsylvania</div>
</div>
.thumbnail-default {
position: relative;
text-align: center;
border: 1px solid #547b97;
background: #e4e4e4;
}
.thumbnail-default:before {
position:absolute;
font-family: 'FontAwesome';
font-size: 72px;
color: #547b97;
text-align: center;
padding: 0px;
margin: 0px;
top: 50%;
transform: translateY(-50%);
}
.card-row-price {
background-color: #009f8b;
bottom: 0px;
color: #fff;
font-size: 13px;
left: 50%;
padding: 3px 15px;
position: absolute;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
white-space: nowrap;
z-index: 2;
}
.card-row-label {
background-color: #c6af5c;
color: #fff;
left: 50%;
font-size: 13px;
padding: 3px 15px;
position: absolute;
top: 0px;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
z-index: 2;
}
.card-row-image {
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
height: 200px;
position: relative;
width: 262px; }
Here is my current output:
Any ideas? Thanks for your time!
set these css codes to make it centered. This happens because on absolute positioned pseudo elements, if you do not specify where to be horizontally (you did not set left or right property), it will follow the text flow and would obey the text-align: center set on the parent.
.thumbnail-default:before { left: 50%; transform: translate(-50%, -50%); }
Working Fiddle

Bootstrap rows overlapping

I am trying to make a page that has two sections that stack on top of each other using rows. Each section is supposed to be the height of the browser window but for some reason the second row overlaps most of the first except for the header.
Here is a link to my code:
http://www.bootply.com/WwcepyZC01
If I understand your question correctly, you can do this using height: 100vh, and remove the position: absolute. I've also restructured your HTML a bit so that .layer2 is not a child of .layer1.
.layer1 {
width: 100%;
height: 100vh;
background-image: url(<%=asset_path "home_bg.jpg"%>);
background-size: cover;
background-color: purple;
}
.title-wide h1 {
top: 10%;
left: 10%;
right: 10%;
color: #ffffff;
font-size: 10vmax;
}
.home-caption {
position: absolute;
left: 20%;
right: 20%;
top: 30%;
}
.title-wide h2 {
color: #ffffff;
font-size: 4vmax;
}
.col-md-7 {
position: absolute;
text-align: center;
left: 15%;
right: 15%;
height: 100%;
top: 50%;
font-size: 10vw;
}
.btn-default {
background: rgba(255, 255, 255, 0.8);
}
.title-wide {
left: 90%;
right: 90%;
}
.btn-xlarge {
padding: 20px 20px;
font-weight: 700;
line-height: normal;
border-radius: 200px;
border: 2px solid none;
text-align: center center;
height: 3em;
font-size: 25px;
width: 10em;
}
.layer2 {
width: 100%;
height: 100vh;
background-size: cover;
background-color: green;
}
<div class="layer1 row-fluid">
<div class="title-wide text-center">
<h1>My Name</h1>
<div class="home-caption text-center">
<h2>I am a person working for a nameless corporation</h2>
<div class="row">
<hr>
<div class="offset4">
</div>
</div>
</div>
</div>
</div>
<div class="layer2 row-fluid">
</div>
<div id="push"></div>