I have a background (used style="background-image:url('')) and 2 images.
I need the images to be positioned this way:
First image:
30px from top of the background
15px from the right
Second image
15px from the bottom of the background
15px from the left
my CSS classse:
myItem1 - first image class
myItem2 - second image class
BgGrass - the background
What i've been trying:
.BgGrass {
background-image:url('images/bg/grass.png');
width:800px;
height:480px;
}
.myItem1 {
position:absolute;
bottom: 15px;
left:15px;
}
.myItem2 {
position:absolute;
top:40px;
right:20px;
}
What's wrong?
Update: The solution here provided that I need to add the position:absolute to my background. The problem now is that all the content below this background is moving up inside it and making a total mess.
<div class='BgGrass'>
<img class='myItem1' src='http://cdn.mysitemyway.com/icons-watermarks/simple-black/raphael/raphael_gear-small/raphael_gear-small_simple-black_128x128.png' />
<img class='myItem2' src='http://iconizer.net/files/Brightmix/orig/monotone_close_exit_delete_small.png' />
</div>
<div class="clearfix"></div>
All content here is inside the background
It would have been easier if we could see the original page you're working on (html specifically)
Anyway, assuming this is your html:
<div class='BgGrass'>
<img class='myItem1' src='http://cdn.mysitemyway.com/icons-watermarks/simple-black/raphael/raphael_gear-small/raphael_gear-small_simple-black_128x128.png' />
<img class='myItem2' src='http://iconizer.net/files/Brightmix/orig/monotone_close_exit_delete_small.png' />
</div>
Then the CSS should be:
.BgGrass {
background-image:url('http://www.planwallpaper.com/static/images/744081-background-wallpaper.jpg');
width:800px;
height:480px;
position:relative;
}
.myItem1 {
position:absolute;
top: 30px;
right:15px;
width: 100px;
}
.myItem2 {
position:absolute;
bottom:15px;
left:15px;
width: 100px;
}
CSSfiddle: https://jsfiddle.net/5ndbzg6h/
Issue: you need to add position relative to your parent div.
From definition here
position:absolute The element is positioned relative to its first positioned (not static) ancestor element
By default, BgGrass is static, so you must give him an other position like relative.
.BgGrass {
background-color:red;
position:relative
width:800px;
height:480px;
}
.myItem1 {
position:absolute;
bottom: 15px;
left:15px;
}
.myItem2 {
position:absolute;
top:40px;
right:20px;
}
<div class="BgGrass">
<div class="myItem1">ABC</div>
<div class="myItem2">DEF</div>
</div>
Related
I have 2 images placed one on top of another, and what I'm trying to do is to change the opacity based on hover on parent.
Meaning that by default hovethumb's opacity is set to 0. But when I hover on index then hoverthumb's opacity should be changed to 1 and bdata's opacity should be changed to 0.5
But the styling doesn't work... The stylings I use are div.productindex:hover > div.hoverthumb & div.productindex:hover > div.bdata
Can someone help me figure out to target them correctly?
My php code :
<div class="index ">
<div class="bdata">
<div class="thumb"><?php the_post_thumbnail('')?></div>
</div>
<div class="hoverthumb clearfix"><img src="<?php echo get_template_directory_uri(); ?>/images/buy.png" width="50px" ;></div>
</div>
also how to align the image exactly in the centre of the box index
.index{
float: left;
height: auto;
padding-bottom:10px;
margin-bottom:20px;
}
.hoverthumb{
position:absolute;
opacity:0;
clear:both;
}
div.index:hover > div.bdata{
opacity:0.5;
border: thin outset #EC008C;
}
div.index:hover > div.hoverthumb{
opacity:1;
}
.thumb{
width:100%;
}
.thumb img{
width:100%;
height: auto;
}
look for division with id shelf and nested division with class inner_div,now the problem is images inside inner_div are not centered after using css class provided below.
CSS CLASS
.inner_div{
display:inline_block;
width:20%;
float:left;
font-size:10px;
text-align: center;
}
.inner_div p{
text-align:center;
margin-left:2px;
margin-right:2px;
/*font-weight:bold;*/
padding:2px;
height:35px;
border-radius:5px;
color:rgb(255,255,255);
background-color:rgb(51,51,51);
}
Simple structure of my catalog
<div id='shelf'>
<div class='inner-div'>
<p>BOOK TITLE<p>
<img src=''></img> //book cover
<img src=''></img // available or not
</div>
<div class='inner-div'>
<p>BOOK TITLE<p>
<img src=''></img> //book cover
<img src=''></img // available or not
</div>
<div class='inner-div'>
<p>BOOK TITLE<p>
<img src=''></img> //book cover // not able to center this two images
<img src=''></img // available or not // not able to center this two images
</div>
.......continues till data available in database
</div>
Try this:
.inner_div img {
display:block;
margin:auto;
}
Try this. You dint specify any css for the images.May be it shud work
.inner_div img {
display: block;
margin-left: auto;
margin-right: auto;
}
I have this following JSfiddle.
This is the HTML markup.
<div id="container">
<img id="rotate" height="80" width="80" src="http://i.imgur.com/dEM0KGG.png" />
<span id="text">Download</span>
</div>
Here is the CSS too.
#container {
position:absolute;
height:80px;
width:80px;
left:0px;
top:0px;
overflow:hidden;
z-index:2147483647;
}
#rotate {
position:absolute;
height:113px;
width:113px;
-webkit-transform:rotate(-45deg);
-webkit-transform-origin:100% 0%;
-moz-transform:rotate(-45deg);
-moz-transform-origin:100% 0%;
-ms-transform:rotate(-45deg);
-ms-transform-origin:100% 0%;
-o-transform:rotate(-45deg);
-o-transform-origin:100% 0%;
transform:rotate(-45deg);
transform-origin:100% 0%;
background:#3868D9;
right:0px;
z-index:9001;
}
#text {
position:absolute;
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-45deg);
-o-transform:rotate(-45deg);
-ms-transform:rotate(-45deg);
transform:rotate(-45deg);
z-index:9001;
top:35px;
right:0px;
}
I want to place a text like how I have shown. The problem I am facing with is that the text can change dynamically and if I use the same position it doesn't display properly.
Is there any way I can position it dynamically based on the width of the text/container?
Also the width of the container can change. Right now its 80 x 80 but can be 50 x 50. How can I position it?
Try rotating the entire #container element, instead of the image and the text separately.
you can't resize the font dynamically, what you can do is to use a little js to solve your problem!
<script type="text/javascript">
setInterval(function(){
var cont=document.getElementById("container").style;
if(cont.width!="80px"){
document.getElementById("text").style.fontSize="9px";
document.getElementById("text").style.top="50%";
}
else{
document.getElementById("text").style.fontSize="16px";}
},1);
just add this code to the head tag
Can anyone explain to me why are my images of left and right arrow not taking any css modifications which are done in their class?
HTML
<div class="carousel-controls">
<div class="carousel-prev"><a href="#" >
<img src="http://localhost:4316/images/Left.png" alt="Previous"/></a></div>
<div class="carousel-next"><a href="#">
<img src="http://localhost:4316/images/Right.png" alt="Next" /></a></div>
</div>
CSS
#waterwheel-carousel-default .carousel-controls .carousel-prev {
position:absolute;
bottom:190px;
left:180px;
height:30px;
width:30px;
border:0px solid black;
}
#waterwheel-carousel-default .carousel-controls .carousel-next {
position:absolute;
bottom:190px;
right:150px;
height:30px;
width:30px;
border:0px solid black;
}
You need to apply particular styles to the img element itself.
For example, if your issue is that a border is appearing on the images, you need to do:
#waterwheel-carousel-default .carousel-controls img {
border:0;
}
Notice I've not included .carousel-prev or .carousel-next in the selector, so that this rule will apply to both
You should target the image like this
#waterwheel-carousel-default .carousel-controls .carousel-prev img
Demo
Cause you designed the div, not the img tag.
You should add
#waterwheel-carousel-default .carousel-controls .carousel-prev img {
...
}
#waterwheel-carousel-default .carousel-controls .carousel-next img {
...
}
I have an unordered html list on:
<ul id="maintab" class="shadetabs">
<li class="selected">selected</li>
<li>not selected</li></div>
I need to use position: relative for "selected" items:
.shadetabs li.selected{
position: relative;
top: 1px;
............
}
Everything is OK so far. But now I want to show a div over all other content of website.
<div id="vertical">
<div id="hoz">
content
</div></div>
#vertical{
position:absolute;
top:50%;
margin-top:-198px;
left:0;
width:100%;
}
#hoz{
width:320px;
margin-left:auto;
margin-right:auto;
height:90px;
border:10px solid #BF0000;
background:#f5f5f5;
text-align:center;padding:10px;
}
Unfortunately, this .shadetabs li.selected is visible trough divs "vertical" and "horizontal". I tried to add style="opacity: 1 !important;" to the "vertical" div but it doesn't help.
Give the element a z-index: 2. That way it will be drawn on top of other positioned content.