Here's my challenge: I have an image of a real property that will be loaded at random in a DIV 200 pixels wide. Accordingly the image will be resized to 200 pixels width and variable height (kept proportional). I have four separate captions that need to go onto the image:
Title
Price
Location
Surface
They need to be positioned respectively on the top center, bottom left, bottom left and bottom right of the picture. So I would have something like:
--------------------------------
| Title |
| |
| |
|Price |
|Location Surface|
--------------------------------
I know that I can overlay text to an image by putting the div in relative position and the text in absolute position, but I only seem to be able to set one position for all text divs below, no matter how many classes I use.
Any advice??
EDIT: Found the solution. For reference, here is the code generated:
<div id="stampRandom">
<img class="stampImg" src="myphoto.jpg">
<div class="title"><span>Title</span></div>
<div class="prix"><span>Location</span><span><br><b>Price</b></span></div>
<div class="surf"><span><b>Surface</span></b></span></div>
</div>
And the CSS:
#stampRandom {
position: relative;
top: 0px;
left: 0px;
width: 200px;
color: #FFF;
font-size: 80%;
}
#stampRandom {
position: relative;
top: 0;
left: 0;
width:200px;
color: #ffffff;
/* text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000; */
font-size:80%;
}
#stampRandom img {
top:0px;
left:0px;
width:200px;
}
#stampRandom div {
position: absolute;
width: 200px;
}
#stampRandom div span {
background: rgb(0, 0, 0); /* fallback color */
background: rgba(50, 50, 50, 0.7);
}
.title {
top:2px;
width:100%;
text-align:center;
}
.prix {
bottom:0px;
left:0px;
}
.surf {
bottom:0px;
right:0px;
text-align:right;
}
Thanks to all who helped out! I was blocked big time and my code needed a major redo. Fresh shot in the arm!
http://jsfiddle.net/h51xLdzg/
<style>
.img-cont{position:relative;width:200px;}
.img-cont div{position:absolute; background:red}
.img-title{top:0px;width:100%;text-align:center;}
.img-price{bottom:0px; left:0px;}
.img-surf{bottom:0px; right:0px;text-align:right;}
</style>
<div class="img-cont">
<img src="/MyImage.jpg" width="200"/>
<div class="img-title">
Title
</div>
<div class="img-price">
Price Location
</div>
<div class="img-surf">
Surface
</div>
</div>
Think this will help you
I made a quick example of how you can accomplish this. It's not perfect but it works. If you need some other help or different approach let me know
http://jsfiddle.net/hg9r7/134/
<div class="imageWrapper">
<img src="http://dummyimage.com/250x200" alt="1" width="250" height="200" />
<div class="top">TOP</div>
<div class="bot">BOT</div>
<div class="botleft">BOTLEFT</div>
<div class="botright">BOTRIGHT</div>
</div>
CSS example for bottom and bottom left text:
.bot{
position:absolute;
background:red;
text-align:center;
margin:0 auto;
width:100px;
left:50%;
margin-left:-50px;
bottom:0;
}
.botleft{
position:absolute;
background:red;
text-align:center;
margin:0 auto;
width:100px;
left:0;
bottom:0;
}
Related
Currently my parent div is showing up as a dimensionless div (0 by 0 px). I am trying to have a flexible parent div thats size is not explicitly mentioned but rather adaps to the size of its content. Here is what I have so far thats producing a 0px by 0px parent. Hope someone can give me a solution.
HTML:
<div class="thumbnailDeal">
<div class="thumbnailImage">
<div class="thumbnailDescription">
<span class="thumbnailTitle">3 Maki Orders</span>
<div class="thumbnailPrices"><span class="thumbnailOriginal">$25</span> $<span class="thumbnailActual">15</span></div>
<br>
<span class="thumbnailRestaurant">New Generation Sushi</span><br>
<span class="thumbnailLocation">11 St Joseph st.</span>
</div>
</div>
</div>
<div class="thumbnailDeal">
<div class="thumbnailImage">
<div class="thumbnailDescription">
<span class="thumbnailTitle">3 Maki Orders</span>
<div class="thumbnailPrices"><span class="thumbnailOriginal">$25</span> $<span class="thumbnailActual">15</span></div>
<br>
<span class="thumbnailRestaurant">New Generation Sushi</span><br>
<span class="thumbnailLocation">11 St Joseph st.</span>
</div>
</div>
</div>
CSS:
.thumbnailDeal{
display: inline-block;
margin:1%;
}
.thumbnailImage{
width:360px;
height:315px;
background-size: cover;
background-image: url(../assets/5.jpeg);
background-position: center center;
background-repeat: no-repeat;
position:absolute;
}
.thumbnailDescription{
height:28%;
width:100%;
background: rgba(0, 0, 0, 0.75);
position:absolute;
bottom:0;
padding:10px;
}
.thumbnailTitle{
color:white;
font-size:17px;
}
.thumbnailRestaurant{
color:#FD8B2B;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:14px;
}
.thumbnailLocation{
color:#9E9E97;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:14px;
position:absolute;
left:0px;
bottom:0px;
padding-left:10px;
}
.thumbnailPrices{
font-size:14px;
color:white;
position:absolute;
right:0px;
bottom:-13px;
box-sizing: border-box;
}
.thumbnailOriginal{
text-decoration: line-through;
color:#9E9E97
}
.thumbnailActual{
font-size:50px;
color:white;
position:relative;
right:10px;
}
When you use position: absolute elements get out of the flow and the parent won't have height/width from his childs anymore.
You have to find another way to position your elements if you want to have a proper height/width to the parent :)
I'm trying to reproduce some pieces of CSS from the http://flink.to website, especially the tiles which contains for each article the picture, the title, the author, the link to the author page and the link to the article.
Here is the HTML for one tile :
<div class="block-module">
<a href="http://flink.to/stories/54b6e61de3039db33f00000b" class="article-link">
<span class="button">View Story</span>
</a>
<img src="https://cdn01.flink.to/api/image/54f492ec30323921c9000000/300/300/fill">
<div class="block-about">
<h2 class="block-title">Arch Enemy’s Perpetual Revolution</h2>
<span class="block-stats">
by Andrew Epstein
</span>
</div>
</div>
Here is the CSS for one tile :
.block-module { width: 283px; height: 283px; font-size: 0.9622em; display: block; cursor:pointer; border-radius:0.3125em; overflow:hidden; z-index:4; position:relative; }
.block-about { position:absolute; bottom:0; left:0; right:0; padding:4em 1em 1em 1em; background-image:-webkit-linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); background-image:linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); }
.block-about a { position:relative; z-index:5; }
.block-title { max-width:100%; margin:0 0 0; color: white !important;font-size:1.625em; }
.block-stats { width:100%; margin-top:0.35714em; font-size:0.875em; color:rgba(255,255,255,0.55) !important; }
.button { color:#ffffff; background-color:#337d94; }
.author-link { color:#659dae; }
Everything's OK except that we can't access the article and the "view story" link which is supposed to show up only when we hover the picture, in the middle/center of it.
Edit : Here is a demo : http://jsfiddle.net/5qwejk20/
As the website's CSS sheet of Flink.to is really very complicated, I didn't find how to resolve this. Could you please help me ?
There is a lot of CSS, and obviously it's hard to tell what does what and it will need to be trimmed. But from what I can tell these are the styles making it happen. The button opacity is initially 0 (hidden), so needed to change to 1.
JSFiddle
I added this style to make it show with the cursor
.view-full-module.mod-custom-icon:hover .button.view-full-custom-el {
opacity: 1;
}
By looking at the css the elements are hiding and showing by using the z-index property and CSS Positioning. Try the following code, I use different values of z-index to overlap elements. Remember that the z-index property only is valid for elements with position:absolute,position:relative or position:fixed so you have to scaffold your website having this on mind. I also added an id to the img to select it on the css. http://jsfiddle.net/cfahhmkj/
HTML
<div class="block-module">
<a href="http://flink.to/stories/54b6e61de3039db33f00000b" class="article-link">
<span class="button">View Story</span>
</a>
<img class="albumImage" src="https://cdn01.flink.to/api/image/54f492ec30323921c9000000/300/300/fill">
<div class="block-about" >
<h2 class="block-title">Arch Enemy’s Perpetual Revolution</h2>
<span class="block-stats">
by Andrew Epstein
</span>
</div>
</div>
CSS
.block-module { width: 283px; height: 283px; font-size: 0.9622em; display: block; cursor:pointer; border-radius:0.3125em; overflow:hidden; z-index:4; position:relative; }
.block-about { position:absolute; bottom:0; left:0; right:0; padding:4em 1em 1em 1em; background-image:-webkit-linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); background-image:linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); }
.block-about a { position:relative; z-index:5; }
.block-title { max-width:100%; margin:0 0 0; color: white !important;font-size:1.625em; }
.block-stats { width:100%; margin-top:0.35714em; font-size:0.875em; color:rgba(255,255,255,0.55) !important; }
.button { color:#ffffff; background-color:#337d94; }
.author-link { color:#659dae; }
.article-link {
position:absolute;
left:110px;
top: 120px;
z-index:-1;
}
.albumImage{
position:absolute;
z-index:0;
}
.albumImage:hover{
z-index:-2;
}
I am trying to set shadow effect for a content and i can be able to set it. But i overlays with adjacent element which disturbs the look. Is there any possible way to remove the overlaying effect for specific area(in the red circle in image)? Pleas check the sample image below.
HTML:
<div id="container">
<div id="table1">
<table>
<tr><td>AAA</td></tr>
<tr><td>BBB</td></tr>
<tr><td>CCC</td></tr>
</table>
</div>
<div id="table2" class="Shadow">
<table>
<tr><td>aaa</td><td>eee</td></tr>
<tr><td>bbb</td><td>fff</td></tr>
<tr><td>ccc</td><td>ggg</td></tr>
<tr><td>ddd</td><td>hhh</td></tr>
</table>
</div>
</div>
CSS:
#container {
position: relative;
}
table,td,tr{
border:1px solid black;
}
#table1{
position: absolute;
}
#table2{
position:absolute;
background-color:pink;
margin-left:40px;
}
.Shadow{
-webkit-box-shadow: 0 0 30px 9px #476FCC;
box-shadow: 0 0 30px 9px #476FCC;
}
JS Fiddle link: http://jsfiddle.net/5JYPm/13/
I think the closest you are going to get is stacking the first table over the second, and ensuring you have a background colour on it:
#table1{
position: absolute;
z-index:2;
background-color:#fff;
}
#table2{
position:absolute;
background-color:pink;
margin-left:40px;
z-index:1;
}
http://jsfiddle.net/5JYPm/16/
you need to change the z-indexs of the tables and then add a background-color to table1
Example
Adjust the box-shadow to the right about half the spread?
.Shadow{
box-shadow: 15px 0 30px 0px #476FCC;
}
JSfiddle
<div id="table2" style="z-index:-1;" class="shadow">
I want to create a photo gallery for one of my projets but I can't achieve it. What I want is something like that :
I don't know how many photo there will be but basically what it does is:
- Insert first photo in photo_div #1
- Insert 2nd in #2
- Goes to new line
- Insert 3rd in #3
- Insert 4th in #4
- Go to next column and first line
- Insert 5th in #5
- etc.
What I've made so far is the following code :
<div id="scroll_container">
<div id="photo_0" class="div_photo">
<!-- More content inside -->
</div>
</div>
And the CSS code :
scroll_container{
height:100%;
width:550px;
overflow-x:scroll;
overflow-y:hidden;
}
.div_photo{
float:left;
width:250px;
height:250px;
border:1px solid black;
margin:0 5px 5px 0;
position:relative;
display:inline-block;
}
But all I can achieve is a two columns gallery with 3 lines.
Could you help me to solve that ?
Thanks
Looks like your images are always of the same size, and that your problem is just the special order that you want.
In that case, this could be a solution:
.test {
width: 40px;
height: 40px;
border: solid 1px blue;
float: left;
margin: 2px;
}
.test:nth-child(4n+3)
{
border-color: red;
position: relative;
top: 44px;
left: -92px;
margin-right: -44px;
}
.test:nth-child(4n+4)
{
border-color: red;
position: relative;
top: 44px;
left: -46px;
margin-right: -44px;
}
fiddle
The idea is to float the first 2 elements, the 5 and 6, and so on. the 3rd and 4th (and 7th and 8th) are positioned relative to take them to the special positions
CSS
.div_photo{
float:left;
width:250px;
height:250px;
border:1px solid black;
margin:0 5px 5px 0;
position:relative;
display:inline-block;
}
.div_photo_1{
float:left;
width:250px;
height:250px;
border:1px solid black;
margin:0 5px 5px 0;
position:relative;
display:inline-block;
}
#scroll_container_1 {
height:auto;
width:257px;
display:inline-block;
}
#scroll_container {
height:auto;
width:514px;
}
#scroll_container_parent {
height:auto;
width:771px;
overflow-x:scroll;
overflow-y:hidden;
}
HTML
<div id="scroll_container_parent">
<div id="scroll_container">
<div id="photo_1" class="div_photo">1</div>
<div id="photo_2" class="div_photo">2</div>
<div id="photo_3" class="div_photo">3</div>
<div id="photo_4" class="div_photo">4</div>
<div id="photo_6" class="div_photo">6</div>
<div id="photo_7" class="div_photo">7</div>
<div id="photo_9" class="div_photo">9</div>
<div id="photo_10" class="div_photo">10</div>
</div>
<div id="scroll_container_1">
<div id="photo_5" class="div_photo_1">5</div>
<div id="photo_8" class="div_photo_1">8</div>
<div id="photo_11" class="div_photo_1">11</div>
</div>
</div>
Modified HTML...may be this should be good
This way you can write your html:
<div id="scroll_container">
<div id="photo_1" class="div_photo">
<!-- More content inside -->1
</div>
<div id="photo_2" class="div_photo">
<!-- More content inside -->2
</div> <div id="photo_3" class="div_photo">
<!-- More content inside -->3
</div> <div id="photo_4" class="div_photo">
<!-- More content inside -->4
</div> <div id="photo_5" class="div_photo">
<!-- More content inside -->5
</div>
</div>
For the 5th one you can apply additional css with id as :
#photo_5 {
display:inline-block;
margin-left:520px;
margin-top:-510px;
}
As you don't want to use table then you can achieve this with css.
Working Fiddle : jsFiddle Working Demo
My code is not working. I found this is because the divs whoch have to change are in an other div... How to bypass the div containing others?
In this example I want the background color change of "partagefb" div when hovering "partage" div
demo: http://jsfiddle.net/u7tYE/1994/
Thanks
html:
<div class="partage" id="partage_70"><img src="/themes/glace_et_ombre/images/partage.png" border="0" width="22" height="21"></div>
<div class="enveloppe_partage">
<div class="partagefb"></div>
</div>
css:
.partage{
position:relative;
float:left;
margin: 2px;
cursor:pointer;
z-index: 100;
width:20px;
height:20px;
}
.partagefb{
position:relative;
width: 25px;
height: 25px;
margin:100px;
background: #ccc;
}
.partage:hover ~ .partagefb{
background-color:#000000;
}
.enveloppe_partage{
position: absolute;
margin: -28px 0 0 115px;
}
The problem is with your selector
use
.partage:hover + .enveloppe_partage .partagefb{
background-color:#000000;
}
Here is the fiddle
Add Id to the div
Make HTML as
<div class="partage" id="partage_70">
<img src="/themes/glace_et_ombre/images/partage.png" border="0" width="22" height="21">
</div>
<div class="enveloppe_partage" id="ank">
<div class="partagefb"></div>
</div>
And CSS could be
#partage_70:hover + .enveloppe_partage #ank {
background-color:#000000;
}