Repeating pseudo element issue in all versions of IE - html

There seems to be an issue in IE 9, 10, 11 and Edge with pseudo elements where if they have a repeating background that is semi-transparent, the first half of the background-image is a lot darker than the rest of the image (almost as if there is overlap between the images). It's fine in all other browsers and seems to be such a unique thing that I couldn't find any references about it anywhere.
The effect that is trying to be achieved is to have an image shown, and a pattern with a certain opacity placed over the top to create a subtle pattern effect. Whilst there are other ways that this could potentially be achieved, this seems to be the easiest way.
Image: Example of what is currently happening.
I made a quick CodePen example. If you look on any version of IE or Edge you'll notice that once the image has been displayed in full already, the second time it is repeated, the first half of the image is noticeably darker than the second half of the image as if that half has a higher opacity on it.
CodePen: Example of the issue with code.
As you can see, the first image with a very basic pattern is fine. The second image though is quite large and has the same issue and I can't figure out what is causing it to do such a thing. Both images are repeating in the exact same way.
This is the code for the pseudo element, nothing out the ordinary in terms of CSS3 attributes or tricks etc.
.element::after {
background-image: url(http://example.com/image.png);
background-repeat: repeat;
width: 100%;
height: 100%;
display: block;
content: "";
opacity: 0.5;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

A very strange bug. No idea why this happens. The problem is in the picture. If you reduce it to 1000px in width, for example, it will work well.
body {
background-color: #232323;
}
.wrap {
width: 100%;
margin: 0 auto;
float: none;
display: block;
}
.slider2 {
width: 100%;
height: 200px;
margin: 10px 0;
padding: 10px;
float: left;
display: block;
box-sizing: border-box;
position: relative;
}
.slider2::after {
content: "";
opacity: 1;
width: 100%;
height: 100%;
display: block;
background-image: url('http://i.imgur.com/tmGMRCB.png');
background-repeat: repeat;
background-position: top left;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<div class="wrap">
<div class="slider2" style="background-image: url(http://img.wallpaperfolder.com/f/4A4B79479EAC/desert-sand-dunes-u6n12nvy10.jpg); background-position: top center;">
Slider 2
</div>
</div>
Solution: try to change picture.

Related

Overlay background image in ng-image-slider

I'm trying to apply a watermark(with an image) to an image inside a carousel. I replaced my previous ngx-bootrap/carousel by ng-image-slider. In my previous code, I use this and it works fine:
.watermarked:after {
content: "";
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
background-image: url("/assets/images/confidential.png");
background-size: 300px 300px;
background-repeat: space;
opacity: 0.9;
}
Now, I find the container in the DOM and located the classs to override the css by my custom watermark css (is what the author recommends):
ng-image-slider .ng-image-fullscreen-view .custom-image-main img {
content: '';
display: block;
background-image: url('/assets/images/confidential.png');
background-size: 300px 300px;
background-repeat: space;
opacity: 0.9;
border: 3px solid orange;
}
It 'works', because while the image is loading, I can see the background with my image, but after the load, it disappears..
While loading:
After the image load, the background get covered and I cannot see anything:
Is this a normal behaviour? Is possible to maintain the background in the front line?
Thanks!
You forgot to use ::after in your example code. Add that to the container of the image since ::after doesn't work on img. I would suggest the following, but make sure that either .custom-image-main or another parent in your slider has position: relative; or the absolute positioning won't work.
.ng-image-slider .ng-image-fullscreen-view .custom-image-main::after {
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-image: url('/assets/images/confidential.png');
...etc
}

::after and ::before elements absolute positioned don't stick to very bottom of body

I'm going nuts! lol
I'm trying to position one image to the bottom of a page but it only works if the page is on large width...say 1360px, but when I shrink the with exactly to the 1206px and less, the body the image is pushed up creating a padding to the bottom as you can see in the image bellow (The image is represented by the green box).
The green image is positioned using this CSS:
body::after {
content: "";
width: 556px;
height: 767px;
position: absolute;
bottom: 0;
right: 10%;
display: block;
background-image: url("imagens/ghost-dog.png");
background-size: contain;
background-repeat: no-repeat;
z-index: -1;
}
And also there is a transparency (this purplish shadow) I added using other property that don't sticky to the bottom too. Using this CSS:
body::before {
background-color: rgba(0, 0, 0, 0.1);
position: absolute;
display: block;
content: "";
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
And last to make my mind go round and round there is a background to the body but it fits ALL screen as expected:
body {
color: #fff;
font-size: 15px;
line-height: 21px;
font-family: "comfortaa-regular";
background-color: var(--cor-roxa);
background-image: url("imagens/logo-bg.svg");
background-repeat: repeat;
}
html, body {
height: 100%;
}
I've already tried to position body relative, but it didn't solve the issue. I don't know if it matter but I'm using bootstrap and my divs are organized like the image below:
Any suggestions?
Without any example to review this is difficult to determine a cause. That said, what immediately comes to mind is a child element with a margin is overflowing it's parent container pushing the window boundary but not it's parent containers boundary.
I would inspect your elements and toggle any margins to see if this has any effect.
If you add your code to a fiddle I can take a look and update this if I notice the issue.

Border at top and left hand side of page with background image

I am putting together a pretty basic website at the moment just as part of my university coursework. I've put in a background image and it nearly fits perfectly - however for some reason I have a white margin at the top of the image (about an inch thick) and a white margin to the left (about half an inch).
here's my css for the image:
#image {
width: 100% 100%;
position: fixed;
z-index: -9;
opacity: 0.8;
display: block;
background-size: cover;
}
I have placed the background image in the html just after the opening body tag as this:
<img id="image" src="CourseworkImages/background2.jpg" alt="Background Image">
I have no idea why I have these margins on the page and they are ruining the look of the page - any help is much appreciated!
Thanks
Instead of using an img tag like you have I would suggest using CSS. Something like:
body {
background-image: url( '/path/to/image.jpg' );
}
You can get rid of a lot of the properties you were using with this approach. The one you'll likely want to keep is background-size.
As others have pointed out, most browsers add 8px of margin to the body element which creates unwanted white space. To remove that, add margin: 0; to the CSS selector above.
To keep the opacity I would use a pseudo element on the body. You could also create a PNG with the desired opacity built in. Using CSS is a bit more flexible.
body {
position: relative;
margin: 0;
min-height: 100vh;
background-color: hotpink;
}
body:before {
content: ' ';
display: block;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -1;
opacity: 0.6;
background-image: url( 'http://placekitten.com/1600/1600' );
background-repeat: no-repeat;
background-size: cover;
}
Pretty basic example:
body {
margin: 0;
padding: 0;
border: 1px solid yellow;
border-right-style: none;
border-bottom-style: none;
width: 100%;
opacity: 0.8;
display: block;
background-size: cover;
background-image: url("CourseworkImages/background2.jpg");
}
You could also do it with a wrapper div. You may also need to play around with background-position and repeat properties. And you also need to reset the browser default margins and paddings in order get really no space between. As I said, basic example. If you are interested in this topic, you could look at css frameworks, that resets all browser-predefined styles, e. g. normalize.css

Strange "Shadow Lines" In Webkit

An issue I'm having is strange lines appearing in certain situations. So far I only notice the issue in Webkit browsers. Also, I know my HTML is not done in the most efficient way, but for the purposes of my project, I would like it to remain the same, unless it is the cause of the issue. For my current work, it happens when I highlight text, or click certain things. This is a big issue since highlighting will be done a lot on my page. Please see my example below, note the extra blue areas in the first image are caused by highlighting text (not shown).
As you can see, when the page loads the lines are not present, however — after using the page for a bit, lines like this appear.
I did my best to recreate the problem in JS fiddle, and I was actually able to. If you highlight text, and then click off the text, you should see a line appear.
Here is my JSFiddle example.
Here is a a picture of the issue reproduced in JSFiddle.
HTML:
<div class="container">
<div class="background-image">
<div class="background-color"></div>
</div>
<div class="box">
<div>Highlight all text</div>
<div>Keep going!</div>
<div>Then click off to deselect</div>
</div>
</div>
CSS:
.container {
width: 500px;
height: 500px;
position: relative;
}
.background-image{
background: url('http://i.imgur.com/4pgHkXy.png') repeat;
-webkit-filter: blur(4px);
filter: blur(4px);
-webkit-transform: scale(1.05,1.05);
transform: scale(1.05,1.05);
top: 0;
left: 0;
width: 500px;
height: 500px;
position: absolute;
top: 0;
left: 0;
}
.background-color {
background: #00adee;
opacity: .5;
width: 500px;
height: 500px;
position: aboslute;
top: 0;
left: 0;
}
.box {
background: #fff;
top: 20px;
bottom: 20px;
width: 200px;
height: 300px;
position: absolute;
}
.box div {
margin: 10px;
width: 180px;
height: 50px;
background: #ccc;
}
If I had to make a guess, I would assume it has something to do with the blur effect?
Any idea how to fix this?
Also reproducible on Mac OS X / Latest Chrome.
This is a bug in Webkit that seems to be caused by combining transform:scale with filter:blur. If I remove the transform in the jsfiddle, the glitch is no longer reproducible: https://jsfiddle.net/2fr6tcgz/
If the only reason you're using scale is to hide the blurry edges of the background, you could use background-size: 105% auto; background-position: center center; as a workaround: https://jsfiddle.net/xa23ja88/ (I also fixed the position: aboslute; typo).
Update:
Apparently the above doesn't fix it completely. But this does: https://jsfiddle.net/o0mupqbo/ (switching the nesting of background image and color). Does that work in your situation?

CSS Layout - div covering screen size

I am a novice at CSS/HTML and need help with a certain issue. I am trying to make my opening div (w/ background image) cover the entire screen (which I have done successfully). The problem is, no matter what I try, I cannot get the next div to start after the initial div. I am including my HTML and CSS. Problem is that I cannot cause #map-contain to start after #opening. Thought it would simply be 'positioning' issue but I cannot solve this. Please help. http://jsfiddle.net/nELQF/ - (need black div to start at bottom of red div)
HTML
<div id="opening">
</div>
<div id="map-section">
</div>
CSS
html, body {
margin: 0;
padding: 0;
min-height: 100%;
width: 100%;
}
#opening {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
border: 1px solid orange;
background-image: url('DSC_0577.JPG');
background-position: center;
background-size: cover;
}
#map-section {
width: 100%;
height: 800px;
background-color: black;
}
Given that the top element is absolutely positioned, you could do the same with the second element and set top:100% in order prevent the elements from overlapping.
Updated Example
#map-section {
width: 100%;
position: absolute;
height: 800px;
top: 100%;
background-color: black;
}
As an alternative, an arguably better approach allowing you to avoid having to absolutely position both elements would be to simply set a height of 100% on the html/body elements.
Example Here