Background image overlapping inserted images - html

I'm playing around with HTML & CSS and is trying to make a pretty simple "under contruction" page. I made the background black and text white. I placed the text where I wanted and are not trying to insert an image below the text. I got the image into the site, but somehow it is behind my background? Anyone who got a clue what to do?
Heres my CSS code:
.fullscreenDiv {
background-color: #000000;
width: 100%;
height: auto;
bottom: 0px;
top: 0px;
left: 0;
position: absolute;
background-attachment:fixed;
}
.center {
position: absolute;
width: 100px;
height: 50px;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -190px;
white-space: nowrap;
font-family: Century Gothic;
font-size: 120%;
color: #FFFFFF;
}
.trademark {
position: absolute;
width: 100px;
height: 50px;
top: 50%;
left: 50%;
margin-top: 250px;
margin-left: 400px;
white-space: nowrap;
font-family: Century Gothic
font-size: 80%;
color: #FFFFFF;
}
And my HTML:
<div class='fullscreenDiv'>
<div class="center">Our website is currently under construction.</div>
</div>
<div class='fullScreenDiv'>
<div class="trademark">#GameAdviser - Copyright 2014</div>
</div>
EDIT:
Just a quick problem now, I made it worked placed my picture, and uploaded it to my FTP, now when I enter the website I can't see my picture, just a border with the "image not aviable" image or whatever it is. Seems strange since I had a picture before which worked fine.
Tried to change it from png to jpeg but didn't make a difference.

You can use z-index like
z-index:199; // for the Element you want on top
z-index:-199; // for the Element you want at bottom

Add z-index property to .center and change the class name fullscreenDiv instead of fullScreenDiv case sensitive.
Try this code:
DEMO
.center {
position: absolute;
width: 60%;
height: 50px;
top: 50%;
left: 20%;
font-family: Century Gothic;
font-size: 120%;
color: #FFFFFF;
z-index: 10;
text-align: center;
}

Related

Div height not filling the screen size when adding images inside it

I am adding two images with a text inside a div which should occupy the whole left side of the screen. When I add the second image at the bottom. Half of the image goes out of the div and and the height of the div is not extended.
The screenshot is the output I am getting
Here is the code:
<section className="App">
<div className="First-Half">
<div className="wrapper">
<div className="Lacazette-Image">
<img alt="Lacazette" src={Lacazette}></img>
</div>
<div className="Arsenal-Fans">
Arsenal Fans
</div>
<div className="Celebrate-Image">
<img alt="Celebrations" src={Celebrations}></img>
</div>
</div>
</div>
#import url('https://fonts.googleapis.com/css?family=Kanit|Lobster|Mansalva&display=swap');
.App {
font-family: 'Lobster', sans-serif;
text-align: center;
display: table;
}
.First-Half {
background-color: red;
position: absolute;
left: 0px;
height: 100%;
width: 50%;
}
.wrapper {
width: 100%;
height: 100%;
position: relative;
}
.Arsenal-Fans {
position: absolute;
height: 50px;
left: 74%;
top: 58%;
font-family: 'Lobster', sans-serif;
font-size: 55px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 1.22;
letter-spacing: normal;
text-align: left;
color: rgba(249, 246, 246, 0.97);
}
.Lacazette-Image img{
position: absolute;
top: 0;
left: 0;
width: 100%;
opacity: 0.8;
border: solid 1px #707070;
}
.Celebrate-Image img{
position: absolute;
width: 100%;
top: 67%;
left: 0;
opacity: 0.8;
border: solid 1px #707070;
}
https://codesandbox.io/s/crazy-bhaskara-6pj9y
By using
position: absolute;
on the images, you are removing them from the flow of the page, and the parent div will not grow with them. Instead of using absolute positioning for layout, you should consider using Flexbox or CSS Grid. These will also help you create a responsive site that will work well on different device sizes.
Here is a short example of how to use Flexbox for layout: https://jsfiddle.net/9swka2gL/
Edit: I like what #novruzrhmv said, but as in the example above, I recommend keeping the whole <h1> together if possible, both for SEO reasons and to make it easier if you collapse to 1 column on mobile. One way to do that is to force just the h1 wrapper to overflow the column as in the example above.
Add following codes to your .css file;
.Arsenal-Fans-In-Lebanon-Image img{width:100%}

How to have Text overlay Image on Banner

I have a banner div element that has a picture overlapping it. I want to have my text not be overlapped by the image, but am having issues.
Example of the problem:
Here is what my html looks like:
.header-banner-container {
background: #221E1F;
position: relative;
width: 100%;
height: 11vh;
top: 38px;
z-index: -1;
}
.header-logo {
position: absolute;
padding-left: 3px;
height: 89px;
width: 92px;
}
.banner-text {
font-family: 'Roboto', sans-serif;
font-size: 11px;
color: white;
position: relative;
top: 50%;
transform: translateY(-50%);
}
<img class="header-logo img" src="../../../assets/CatPicture.png">
<div class="container-fluid header-banner-container">
<span class="banner-text">There is a cat above me</span>
</div>
My questions are:
Should the image be in the container-fluid div, as a best practice? Or is having it outside the banner as I do currently, correct?
How can I get the text to not be overlapped by the image?
Thanks for any advice for the questions, and any other advice you may have!
If the image is a logo or something that belongs in the header, then yes, you should keep the image in the header container, and the text too. You could resolve the issue of the overlapping text easily by simply increasing the vh of the container div and moving the banner-text top attribute down slightly this way.
However, if the case is other than above, and you want to keep the text in that position but make it visible, then you could move the banner text out of the text and position it absolutely from the top. As-is, adjusting the z-index to 0 (e.g.) while it is still within the container div would have no effect as the container div's z-index of -1 would take precedence, and if adjusted higher, would overlap the image also.
Hope this helps
.header-banner-container {
background: #221E1F;
position: relative;
width: 100%;
height: 11vh;
top: 38px;
z-index: -1;
}
.header-logo {
position: absolute;
padding-left: 3px;
height: 89px;
width: 92px;
}
.banner-text {
font-family: 'Roboto', sans-serif;
font-size: 11px;
color: white;
position: absolute;
transform: translateY(-50%);
top: 70px;
z-index: 0;
}
<img class="header-logo img" src="http://ssl.gstatic.com/images/icons/gplus-32.png">
<div class="container-fluid header-banner-container">
</div>
<span class="banner-text">There is a cat above me</span>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Example</title>
<style>
.header-banner-container {
background: #221E1F;
position: relative;
width: 100%;
height: 11vh;
top: 38px;
z-index: -1;
}
.header-logo {
position: absolute;
padding-left: 3px;
height: 89px;
width: 92px;
border-radius: 100%;
}
.banner-text {
font-family: 'Roboto', sans-serif;
font-size: 15px;
color: white;
position: absolute;
transform: translateY(-50%);
top: 49px;
z-index: 0;
left: 50px;
text-shadow: 0px 3px 3px black;
}
</style>
</head>
<body>
<img class="header-logo img" src="https://image.freepik.com/free-vector/geometric-background_23-2148064464.jpg">
<div class="container-fluid header-banner-container">
</div>
<span class="banner-text">There is a cat above me</span>
</body>
</html>

Why is my text align not working?

Here is the code.
The text align wont work.
html {
position: fixed;
top: -50px;
background-color: #c4f3ff;
}
div {
width: 100%;
height: 50px;
text-align: center;
}
h1 {
font-family: monospace;
line-height: normal;
color: #fffb29;
font-size: 50px;
position: fixed;
top: -20px;
}
Here is a screen shot of the result
You mean the yellow text need to be align to center/right or somewhere?
If so, you just use:
h1{
width:100%;
text-align:center;
}
In your css file you marked your html (??) and all your divs with
position: fixed;
Position fixed elements will need a width as well. add
width: 100%;
or
width: 100vw;
So it can center your text.

Css alignment & positioning of html5 video tags

I have two video tags which I want to align at bottom corner of the screen. further, the inner video tag should overlap outer video tag, like this image given below:
This is what I could come up with:
<body>
<div class="container">
<div class="widget_contaner">
<div class="widget_head">this is head of widget</div>
<div class="widget_body">
<video class="large_video" src="#"></video>
<video class="mini_video" src="#"></video>
</div>
</div>
</div>
</body>
css
.widget_contaner {
right: 0px;
position: fixed;
bottom: 30px;
z-index: 99999999999999;
}
.widget_header {
background-color: #3fa757;
width: 240px;
text-align: center;
text-transform: uppercase;
font-weight: bold;
border: 1px solid #ccc;
font-size: 12px;
height: 25px;
line-height: 25px;
font-family:'Open Sans', sans-serif;
border-radius: 5px;
}
.widget_body {
width: 240px;
height: 150px;
}
.large_video {
height: 100%;
width: 100%;
}
.mini_video {
position: absolute;
height: 30%;
width: 30%;
bottom: 32px;
right: 4px;
opacity: 0.75;
}
so I was wondering how can I get these video tags to get positioned relative to each other as just given in the image?
Jsfiddle: click here
Like this?
http://jsfiddle.net/EbsaL/3/
I added background colour so it is easier to see
.widget_body {
width: 240px;
height: 150px;
position: relative;
}
.large_video {
height: 100%;
width: 100%;
background: green;
}
.mini_video {
position: absolute;
height: 30%;
width: 30%;
top: 0px;
right: 0px;
opacity: 0.75;
background: purple;
}
The widget body is positioned relatively, and you just need to give the mini video position absolute and top right 0px. If you want the widget positioned at the bottom right corner then do bottom:0; for widget container
See if this is what you are looking for. Note that I changed the background and borders so I could see it. Mainly needed to add absolute positioning to the larger video frame along with some bottom properties set to 0.
.large_video {
height: auto;
width: 100%;
border: 2px solid #000;
position: absolute;
bottom: 0;
}
http://jsfiddle.net/derekstory/EbsaL/2/

CSS div with relative positioning not working right in IE

I'm placing a big image on top of a couple div layers with relative positioning. I'm also using top: -170px; to pull the image up to exactly where I need it to be. It works perfectly in Firefox, but in IE it won't adjust the position of the blue bar beneath it to account for the negative top positioning.
If I don't make sense, you can have a look at the live development site:
http://www.suncastmedia.com/clients/ezbook/
You'll see what I mean if you look in both firefox and IE. Here is my CSS for these specific divs as well.
#red-box {
width: 100%;
height: 343px;
background: url('../images/bg-red.png') top left repeat-x;
text-align: left;
}
#red-box-text {
position: relative;
left: 70px;
top: 45px;
font-size: 18px;
font-weight: bold;
color: #fff;
font-family: helvetica;
width: 451px;
}
#spacer {
width: 100%;
height: 8px;
}
#blue-box {
width: 100%;
height: 29px;
background: url('../images/bg-blue.png') top left repeat-x;
}
#pic-globe {
position: relative;
top: -170px;
left: 52%;
background: url('../images/pic-globe.png') top left no-repeat;
width: 506px;
height: 471px;
}
You could switch #pic-globe and #red-box-text around, then add float: right; to #pic-globe. Generally, if you are using huge, negative margins, there might be an easier way to do it.