Place one image on top of the other [closed] - html

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I need to place my second picture (img id="stack") on top of my first picture. I've tried using relative and absolute positioning but it just seems to be below each other.
This is the JS Fiddle
HTML
<div id="imgpos">
<img id="bkgr" src="http://upload.wikimedia.org/wikipedia/commons /f/fd/Moon_in_Sunrise_Sky_2.jpg" width="400" height="400">
<img id= "stack" src="http://upload.wikimedia.org/wikipedia/commons/1/16/Appearance_of_sky_for_weather_forecast%2C_Dhaka%2C_Bangladesh.JPG" width="200" height="150">
</div>
CSS
#imgpos
{
position: relative;
left: 30px;
}
#imgpos bkgr
{
position: absolute;
z-index: 1;
}
#imgpos stack
{
position: absolute;
z-index: 2;
}

You forgot the octothorpe.
#imgpos #bkgr
{
position: absolute;
z-index: 1;
}
#imgpos #stack
{
position: absolute;
z-index: 2;
}
Since IDs are unique anyways, you can omit the #imgpos, too:
#bkgr {
position: absolute;
z-index: 1;
}
#stack {
position: absolute;
z-index: 2;
}
And since the images are in the right order anyways, you can omit the z-index, too:
#bkgr {
position: absolute;
}
#stack {
position: absolute;
}
And since the rules are now the same, you can combine them:
#bkgr, #stack {
position: absolute;
}

Related

CSS ERRORS at-rule or selector expectedcss(css-ruleorselectorexpected) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 months ago.
Improve this question
I received 3 errors in the following code;
<style media="screen">
.sqs-audio-embed{
visibility: hidden;
}
Error 1: at-rule or selector expectedcss(css-ruleorselectorexpected)
Error 2: { expectedcss(css-lcurlyexpected)
Error 3: at-rule or selector expectedcss(css-ruleorselectorexpected)
This is the entire .css file
div {
font-family: Arial, Helvetica, sans-serif;
font-size: 80px;
color: #fff;
position: absolute;
left: 150px;
top: 200px;
}
.post-content{
opacity: 0.5;
top: 0px;
left: 0px;
position: absolute;
}
.thumbnail{
position: relative;
}
<style media="screen">
.sqs-audio-embed{
visibility: hidden;
}
.root{
--main-bg-color: brown;
}
I tried to search for a solution but I had no luck. Can someone explain these errors and explain how to correct them?
Thanks In Advance!
You said it's in ".css" file. <style> is an html element, so you should not use it inside css file. I think you should use media queries instead, something like this:
#media screen {
.sqs-audio-embed {
visibility: hidden;
}
}
please refer MDN Docs for more information.

Add a background colour with opacity to an img tag [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am restricted to adding an any additional HTML markup to create an overlay div to do this.
However with the markup I have I need to put a dark overlay with opacity over the top of the image.
background: rgba(0, 0, 0, 0.5);
Markup is:
<div class="fusion-image-wrapper">
<a href"#">
<img src="image-path" >
</a>
</div>
Any ideas?
Thanks
You can use ::after so you don't have to add another element
.fusion-image-wrapper a {
position: relative;
display: block;
}
.fusion-image-wrapper a::after {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1;
}
So you need a transparent image over a black background :)
.darkenImage{
display: inline-block;
background: #000; /* :) */
}
.darkenImage img {
vertical-align: middle;
opacity: 0.5; /* :) */
}
<a class="darkenImage" href="#">
<img src="https://loremflickr.com/cache/resized/4698_27827105189_d6ce3f3401_n_300_200_nofilter.jpg" >
</a>
And if you use a mix of .jpg and .png images you can add background: #fff; to the img styles.

:after pseudo-element not appearing [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm building a scalable mobile menu icon and the :after pseudo class is not working. This is intended to create 3 black lines to represent the "hamburger" menu icon. The first line is created, the second line is created using the :before pseudo class, however the :after pseudo class is not rendering, thus the third black line is not appearing.
JS Fiddle - https://jsfiddle.net/eeks1swx/
I'm not entirely sure why and I can't seem to figure it out. Any thoughts?
.hamburger {
height: 15px;
width: 20px;
position: relative;
display: block;
cursor: pointer;
box-sizing: border-box;
}
.hamburger__line:before,
.hamburger__line:after,
.hamburger__line {
position: absolute;
height: 20%;
background-color: #000;
width: 100%;
border-left: 0;
border-right: 0;
top: 40%;
}
.hamburger__line:before,
.hamburger__Line:after {
content: "";
height: 100%;
}
.hamburger__line:before {
top: -200%;
}
.hamburger__line:after {
top: 200%;
}
<div class="hamburger">
<div class="hamburger__line"></div>
</div>
.hamburger__line:before,
.hamburger__Line:after {
content: "";
height: 100%;
}
... you have an uppercase L - classes are case sensitive.

Progress bar inside table cell [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to add progress to table cell background. Here's fiddle: http://jsfiddle.net/kedctfmj/3/
HTML:
<table>
<tr>
<td>value1</td>
<td>
value2
<div class="bg" style="width: 20%"/>
</td>
<td>value3</td>
</tr>
<tr>
<td>value4</td>
<td>
value5
<div class="bg" style="width: 30%"/>
</td>
<td>value6</td>
</tr>
</table>
CSS:
table {
width: 300px;
}
tr:nth-child(odd) {
background-color: #f8f8f8;
}
td {
border: 1px solid #ccc;
}
td {
position: relative;
}
.bg {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background-color: #8ef;
z-index: -1;
}
Closest I was able to achieve is with z-index: -1. But this doesn't play well with tr's background color.
Add a very little opacity to tr elements (so that new stacking context is created for tr elements) and then z-index: -1 will work as expected:
tr:nth-child(odd) {
background-color: #f8f8f8;
opacity: .999;
}
.bg {
/* ... */
z-index: -1;
}
Demo: http://jsfiddle.net/kedctfmj/5/
Another problem that potentially may cause troubles in IE is self-closing <div /> tags. This is not valid syntax, it should have closing tags </div>:
<div class="bg" style="width: 20%"></div>
Have you considered changing the opacity of the .bg item so that the value can still be displayed?
Using the code from your fiddle:
.bg {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background-color: #8ef;
opacity: 0.5;
/*z-index: -1;*/ }
Hope this helps...
-- Lance

Give position to a dynamic box in css [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am writing a web page but
I have a problem to position :after of .posts to bottom-right in all boxes.
Example in jsfiddle:
.posts::after {
content: " ";
width: 0;
height: 0;
border-top: 15px solid #DDD;
border-right: 13px solid transparent;
position: relative;
bottom: -41px;
right: -2px;
z-index: 999;
}
How can I achieve this?
http://jsfiddle.net/mu222/2/
Give .posts a position (relative), then set the after to position: absolute; bottom: 0; right: 0