transparent background-color not working - css

i have this issue with bootstrap 4: i'm working on a web page and i've put a fixed background with css. I want to put multiple <div> one under another, with some transparent space between them, in order to see pieces of the background image in these transparent spaces. The problem is that bootstrap (i guess) makes every kind of background text to be white-coloured so the transparent thing doesn't work. I created a "spazioVuoto" class in css that should make the background transparent, but it doesn't. Can anyone help me?
PS. if you want to see an example of what i'm talking about, look at http://it.diesel.com/it/
here is a codepen example https://codepen.io/anon/pen/ooJqVK
this is my code
html {
background: url(img/background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.spazioVuoto {
background-color: transparent;
padding: 5em;
}

The problem here is that your body have a backgournd-color:#fff, so even if spazioVuoto have background transparent the color will be still white because of that. Try to change it (spazioVuoto background-color) to red and you will see that it will work. So you have to put the body background to transparent and then work on other containers to set their background-color.
html {
background: url("w3schools.com/w3css/img_fjords.jpg")
no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body {
background-color:transparent !important;
}
.spazioVuoto {
background-color: transparent;
padding: 5em;
}
.container {
max-width: 100% !important;
background-color: #fff;
width: 100% !important;
padding: 1% 20% !important;
}

Related

Bootstrap4 Carousel caption background color not working for me

I'm trying to get an opaque background on the carousel caption text. A similar problem was reported in February so I think my code format is correct. Any comments are appreciated as I can't think of anything else to try.
.carousel-item {
height: 65vh;
min-height: 300px;
background: no-repeat center center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.portfolio-item {
margin-bottom: 30px;
}
.carousel-caption {
background: rgba(0, 0, 0, 0.65%);
}
The last parameter should be between 0 and 1. In your case, you chose the value 0,65% which is equivalent to 0,0065, that's why you cannot notice the color.
If you want to set it to 65% of opacity, either you set it to 65% or to 0,65.
For more informations, check this URL :
https://www.w3schools.com/css/css3_colors.asp#:~:text=RGBA%20color%20values%20are%20an,and%201.0%20(fully%20opaque).

background pic 2 scenarios - 1 height is big, other is small

I have 2 scenarios of background picture in a navbar (I think that is where it is located - I am a beginner w/css).
The height of the background image in the following is big:
.navbar-brand {
font-size:1.5em
}
header {
background-image: url(../../images/backpic.jpg);
background-repeat: none;
background-attachment: scroll;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
text-align: center;
color: #fff
}
The height of the background image in this second one is small:
.navbar-default.navbar-shrink .navbar-brand {
font-size:1.5em
}
header {
background-attachment: scroll;
background-position: center center;
background-repeat: no-repeat;
text-align: center;
color: #fff;
background-image: url(../../images/backpic.jpg);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I am trying to make the height of the second one, just a little bigger, but not as big as the first one.
I also want to add a nice container in the under the middle left part of the navbar i.e. the "ASDFADF" lettering part.
Any help would be great..
First things first, let's clean up your styling a little bit. All the background properties that you've declared can be combined into one shorthand called background. Here's your code cleaned up:
.navbar-brand {
font-size:1.5em
}
header {
background: url(../../images/backpic.jpg) center center / cover no-repeat;
text-align: center;
color: #fff
}
The background-size no longer requires vendor prefixes and can be combined into the above declaration.
Next, to increase the size of the second image background, do the following:
.navbar-default.navbar-shrink .navbar-brand {
font-size:1.5em
}
header.smaller {
background: url(../../images/backpic.jpg) center center / cover no-repeat;
background-size: 125%; /* Adjust this value to the desired size */
text-align: center;
color: #fff;
}
You'll want to add a different class to the second container so you can target that separately (since they both use the same base element selector).

Invert background image of parent element with CSS

I have kind of a hard problem here (I think). Assume the following HTML:
<div id="page">
<div id="menubar"></div>
</div>
With the following CSS defined on it:
#page {
background: url("some-image.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#menubar {
background-color: rgb(36, 108, 228);
background-color: rgba(0, 50, 255, 0.6);
}
In words, I have a page div with a fully covering background image and a menubar with a 60% opacity, so the background of div #page shines through the menubar. However, I would like to have the background shining through the menubar AND invert the colors of the background where it shines through the menubar.
I could not find a solution online, since the invert filter can only be applied to entire images as far as I am aware. So therefore, I really hope that someone on SO knows some nice trick to pull this of.
Thanks in advance!
Technically you don't need to "target" the parent's background image.
In CSS you can just inherit the properties of the parent into the child element.
#page {
background: url("http://lorempixel.com/1280/720/nature/") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
/* Copy the parent's image properties */
#menubar {
background: inherit;
}
Another option would be to just have #page and #menubar selectors on the same declaration.
#page, #menubar {
background: url("http://lorempixel.com/1280/720/nature/") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Either way, once you give the #menubar the same background, you can add another rule to invert the colors on the #menubar.
#menubar {
-webkit-filter: invert(100%);
filter: invert(100%);
}
JSFiddle
Note: Added invert and background color to the the child element just inside the #menubar to revert the colors.

Fullscreen background img combined with Fullscreen repeating background

I'm trying to place a fullscreen background image combined with a repeating background image without the use of J-query. Is it possible?
This is the code I use to get my image fullscreen:
body {
background: url(../img/bg1.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
But now I want this completely overlapped by a .png image background that needs to have a repeat function, for the simple reason that the .png contains lines which will rescale and look awful on certain screen sizes.
Any ideas?
Already tried:
Giving html a background and body a background, it will only display one of both.
Be aware that multiple backgrounds won't work on ie8 if needed:
http://caniuse.com/multibackgrounds
This answer will work on every browser:
You must give width and height to the elements.
You can see answer here: http://jsfiddle.net/Rc38f/
HTML Code:
<html>
<body>
<div id="wrapper"></div>
</body>
</html>
CSS Code:
html {
width: 100%;
height: 100%;
}
body {
background-image: url('http://www.colourbox.com/preview/4632391-637684-seamless-small-white-flowers-pattern-background.jpg');
background-repeat: repeat;
width: 100%;
height: 100%;
}
#wrapper {
background: url('http://i.telegraph.co.uk/multimedia/archive/02403/Jonstockshooting_2403237b.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 100%;
height: 100%;
}
It is possible to include two background images on one tag.
How it Works
Multiple background images can be specified using either the
individual background properties or the background shorthand property.
This should be a Helpful resource to get you started.
css:
body {
background-image: url(http://www.wallcoo.com/paint/Chiplegal_vector_art/images/%5Bwallcoo.com%5D_vector_art_0seasons.jpg), url(http://nopgc.org/v2/images/body_bg.jpg);
background-position: top center, center;
background-repeat: no-repeat, repeat;
width: 100%;
height: 100%;
}
fiddle: Demo

CSS fixed background has white line on the left

I tried to put a background on my whole page with
html {
background: url(images/panda.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
This generally works just fine, but I have discovered a problem: On the left-hand side of the screen is a white stripe. Is it possible to fix that?
PS: Just in advance: No, that stripe is not on the picture. You can get an impression of how it looks:
EDIT: http://jsfiddle.net/uhwcW/
When zooming in/out the white stripe sometimes disappears or switches sides... Confusing.
Try;
margin: 0;
padding: 0
in your CSS for html.
Have you tried to reset your body? Try this for other containers too, maybe it's just some margin or padding you're seeing...
body {
margin: 0;
padding:0;
}
this worked for me..
html{
background: url(..//index3.jpg) no-repeat 0 0 fixed;
-webkit-background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
-moz-background-size: cover;
}
Just adding a center after the url did it for me
like this:
background: url(images/panda.jpg) center;

Resources