This question already has answers here:
Overlapping/overlaying multiple inline images
(2 answers)
Closed 4 months ago.
i'm trying to create a row with many photos, example;
but i'm having trouble to create the border radius negative.
like this.
i've been trying in this codepen
CodePen
HTML
<div class="d-flex">
<a class="d-inline">
<img alt="project member" class="rounded-circle thumb48" src="https://i.imgur.com/C7sGXc6.png">
</a>
<div class="d-inline person">
<img alt="project member" class="rounded-circle thumb48" src="https://i.imgur.com/C7sGXc6.png">
</div>
<a class="d-inline">
<img alt="project member" class="rounded-circle thumb48" src="https://i.imgur.com/C7sGXc6.png">
</a>
</div>
CSS
.thumb48{
width: 48px !important;
height: 48px !important;
}
.rounded-circle{
border-radius: 50% !impor
}
.d-flex{
display:flex !important;
}
.d-inline{
display: inline !importante;
}
.person{
background-color:red;
position:relative;
}
.person:before
{
width: 10px;;
height: 68px;
border-radius:0 50% 50% 0;
background-color:#FFF;
display:inline-block;
vertical-align: middle;
content: '';
}
You can achieve this cutout effect by putting a solid border on each image that is the same colour as the background:
<div class="circle-overlap">
<img alt="project member" src="https://i.imgur.com/C7sGXc6.png">
<img alt="project member" src="https://i.imgur.com/C7sGXc6.png">
<img alt="project member" src="https://i.imgur.com/C7sGXc6.png">
</div>
.circle-overlap img {
width: 50px;
border-radius: 50%;
border: solid white 5px; // Change to a different colour to visualise more clearly what’s happening
margin-right: 2px;
position: relative;
background: teal;
}
.circle-overlap img:nth-of-type(2) {
left: -25px;
z-index: -1;
}
.circle-overlap img:nth-of-type(3) {
z-index: -2;
left: -50px;
}
Related
This is my sample html code:
.questions-table-main {
border-right: 3px solid rgb(242,244,247);
width:189px;
float:left;
padding-right:30px;
padding-top:10px;
display:table;
height: 200px;
}
.questions-table-main-category {
/* padding-top: 20px; */
text-align : center;
}
.questions-table-main-firm {
height:85px;
background-color:rgb(242,244,247);
text-align: center;
display: table-row;
vertical-align: bottom;
}
<div class="questions-table-main">
<div class="questions-table-main-category">
<img src="img/communication.png" alt="communication"/>
</div>
<div class="questions-table-main-firm">
<div class="questions-table-main-firm-image">
<span class="questions-table-firm-helper">
<img src="img/allianz.png" alt="allianz" /></span>
</div>
</div>
</div>
Let me clear this mess. I need to put <div class="questions-table-main-firm"> on the bottom of <div class="questions-table-main">. Next thing I need to do is that <div class="questions-table-main-category"> must be above <div class="questions-table-main-firm"> with 27px space between them. I was trying to do that with padding-top, but it's impossible because i have some different images with different dimensions. Now <div class="questions-table-main-category"> is on the top of parrent div. How to fix that ?
You can do it by using position: absolute; and top. For bottom div use top: 0 so that it says at top and for first div use top: 112px including height(85) and margin 27.
.questions-table-main {
border-right: 3px solid rgb(242,244,247);
width:189px;
padding-right:30px;
padding-top:10px;
display:block;
height: 200px;
position: relative;
}
.questions-table-main-category {
text-align : center;
height:85px;
top: 112px; /* height 85 + 27 margin*/
position: absolute;
}
.questions-table-main-firm {
height:85px;
background-color:rgb(242,244,247);
text-align: center;
top: 0px;
position: absolute;
}
<div class="questions-table-main-category">
<img src="https://placehold.it/189x85" alt="communication"/>
</div>
<div class="questions-table-main-firm">
<div class="questions-table-main-firm-image">
<span class="questions-table-firm-helper">
<img src="https://placehold.it/189x85" alt="allianz" /></span>
</div>
</div>
</div>
You need to remove the display table atributes, do it as follows:
.questions-table-main {
width:189px;
float:left;
padding-right:30px;
padding-top:10px;
height: 200px;
}
.questions-table-main-category {
/* padding-top: 20px; */
text-align : center;
margin-bottom: 27px;
}
.questions-table-main-firm {
background-color:rgb(242,244,247);
text-align: center;
vertical-align: bottom;
}
<div class="questions-table-main">
<div class="questions-table-main-category">
<img src="http://placehold.it/350x150" alt="communication"/>
</div>
<div class="questions-table-main-firm">
<div class="questions-table-main-firm-image">
<span class="questions-table-firm-helper">
<img src="http://placehold.it/350x150" alt="allianz" /></span>
</div>
</div>
</div>
I have a problem with image descriptions. I have HTML structure like this:
<div class="scrollable-content" data-mcs-theme="dark-thick" style="padding: 0px; overflow-x: auto;">
<ul style="list-style: none; white-space:nowrap; padding: 0px;">
#foreach($projects as $project)
<li style="display: inline; margin: 0px;">
<a href="{!! url($locale.'/projects/project/'.$project->id) !!}">
<img class="project-cover-image" src="/images/{!! $project->cover_image_name !!}" height="250px" width="auto">
</a>
</li>
#endforeach
</ul>
</div>
It creates a nice looking gallery with horizontal scrollbar. But I need to add descriptions to images that will be placed at the bottom of the pictures covering whole their widths and they should have to be transparent to some degree.
The problem is, whatever I do, I either get description that takes 100% width of the page, or it has width of the text inside it.
I have tried doing it with div, span, different combinations of position absolute/relative, everything and I couldn't manage to make it work.
It should look something like this:
How can I do that?
You have two options (wich produce the same result):
1- A div with a image as background, and a subtitle inside this div;
#image {
width:550px;
height:150px;
position:relative;
background: url('http://i.imgur.com/HNj6tRD.jpg');
background-repeat: no-repeat;
background-size:100% 100%;
}
.coverdown {
color: white;
width: 100%;
height: 30%;
position:absolute;
bottom:0%;
background: rgba(0,0,0,0.5);
text-align: center;
}
<div id="image">
<div class="coverdown">Subtitle here with a description.</div>
</div>
2- The image and a subtitle with position:absolute inside a position:relative container;
#container {
width:550px;
height:150px;
position:relative;
}
img {
width:550px;
height:150px;
position:absolute;
top:0px;
left:0px;
}
.subtitle {
color: white;
width: 100%;
height: 30%;
position:absolute;
bottom:0%;
background: rgba(0,0,0,0.5);
text-align: center;
}
<div id="container">
<img src="http://i.imgur.com/HNj6tRD.jpg" alt=img>
<div class="subtitle">Subtitle here with a description.</div>
</div>
use position:relative/absolute
body {
margin: 0
}
.scrollable-content {
padding: 0;
overflow-x: auto
}
ul {
list-style: none;
white-space: nowrap;
padding: 0;
margin:0
}
li {
position: relative;
display:inline-block
}
span {
background: rgba(0, 0, 0, .5);
display: inline-block;
height: 50px;
position: absolute;
bottom: 0;
left: 0;
width: 100%
}
img {
display: block
}
a {
color: #fff
}
<div class="scrollable-content" data-mcs-theme="dark-thick">
<ul>
<li>
<a href="">
<img class="project-cover-image" src="//lorempixel.com/250/250">
<span>description</span>
</a>
</li>
<li>
<a href="">
<img class="project-cover-image" src="//lorempixel.com/500/250">
<span>description</span>
</a>
</li>
<li>
<a href="">
<img class="project-cover-image" src="//lorempixel.com/400/250">
<span>description</span>
</a>
</li>
</ul>
</div>
basicly, you need relative/absolute as #dippas's answer.
as I advised, use inline-block, so it gets sized by content and will allow easily to position your description.
example below with figure and figcaption.
figure can be wrap in a <a>link displayed inline-block and figure as a block then to avoid a gap underneath.
figure {
display: inline-block;
position: relative;
margin: 0;
}
img {
display: block;
max-height:80vh;height:250px/*snippet demo purpose */
}
figcaption {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
/* makeup*/
background: rgba(0, 0, 0, 0.5);
color: white;
}
/* demo purpose */
div {
white-space: nowrap;
overflow:auto;
}
figure {
white-space: normal;
text-align: center;
}
<div>
<figure>
<img src="http://www.hyperkreeytiv.com/wp-content/uploads/2014/08/IMG_4973.jpg" alt="wolves" />
<figcaption>
<p>these are wolves</p>
</figcaption>
</figure>
<figure>
<img src="http://4.bp.blogspot.com/-oSEWgZNEopE/TtL8kfGuBzI/AAAAAAAAB6U/b8VSzZaoK3g/s400/action_wolf_1111_photo1.jpg" alt="wolves" />
<figcaption>
<p>these are wolves</p>
</figcaption>
</figure>
<figure>
<img src="http://1.bp.blogspot.com/-GfOyrk3kZ0w/TewM0BMvbNI/AAAAAAAABM0/KPm3li5Xwko/s1600/alpha+male+Wallpaper__yvt2.jpg" alt="wolves" />
<figcaption>
<p>these are wolves</p>
</figcaption>
</figure>
<figure>
<img src="http://www.ooyuz.com/images/2015/10/13/1447449028465.jpg" alt="wolves" />
<figcaption>
<p>these are wolves</p>
</figcaption>
</figure>
</div>
I have been trying to add an overlay play icon to my videos which all works however after adding this im getting a weird 1px spacing on the bottom row of my images
When the absolute positioning is removed from (#icon) the images align perfectly - but when added back it adds the weird spacing
Could anybody help with this?
CODE: http://www.codeply.com/go/JC75OR4xpD
HTML CODE:
<div class="instaVideos">
<h1>Short Videos</h1>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xaf1/t50.2886-16/11661388_407770589406910_367605487_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-15/11325016_1163164417043690_1908545167_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xtp1/t50.2886-16/1489765_333969910114258_1680134671_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/10706968_601233316654119_1567865956_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xaf1/t50.2886-16/10679292_519402934860781_468618633_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-15/10665576_441425795996740_1661178998_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xfp1/t50.2886-16/10641919_684721938283340_2079757675_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xap1/t51.2885-15/924582_890120924350870_1658010424_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xfp1/t50.2886-16/10541299_371884109631916_1548975081_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-15/10538735_664550930296554_1249448005_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="https://scontent-lhr3-1.cdninstagram.com/hphotos-xaf1/t50.2886-16/11683107_112731029066100_1538573428_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/11386568_1455668744729300_108311835_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xfp1/t50.2886-16/10721731_1471532036461241_1447645097_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-15/10724656_765518650158719_1752400817_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
<a href="http://scontent-lhr3-1.cdninstagram.com/hphotos-xfa1/t50.2886-16/11679305_467034590127593_1579081935_n.mp4" class="html5lightbox">
<img src="https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-15/11429736_699224963557660_1457167025_n.jpg"/>
<img id="icon" src="img/youtubePlayIcon.png"/>
</a>
</div>
CSS:
.instaVideos {
margin:0 auto;
margin-left: auto;
margin-right: auto;
max-width: 800px;
width:90%;
text-align: center;
margin-bottom: 50px;
transition:all .2s ease-in-out;
}
.instaVideos > h1 {
margin:0 auto;
text-align: left;
width:300px;
margin-left: 2%;
font-size: 30px;
font-family: 'raleway';
}
.instaVideos > a > img {
width:150px;
height:auto;
margin-top: 5px;
border:1px solid red;
text-align: center;
}
.instaVideos a:hover {
opacity: 0.7;
}
.instaVideos > a {
position:relative;
}
#icon {
width:auto;
height:30px;
position:absolute !important;
left:35%;
top:0px;
right:0px;
display:inline !important;
}
SOLVED
I fixed this by doing the follwing:
.instaVideos {
position:relative;
}
#icon {
position: absolute;
left:0;
right:0;
top:0;
margin: 0 auto;
}
Maybe this help you: Fiddle
CSS:
.instaVideos > a {
position: relative;
height: 100%;
width: auto;
display: inline-block;
}
#icon {
width:auto;
height:30px;
position:absolute !important;
left:50%;
top:50%;
transform: translate(-50%, -50%);
}
I currently have a blog which needs to display profiles (agency style) lists 4 in a line, I've design the website so that when its responsive, and i want these profiles to work responsively. At this time it works, but when using 50% without margins, but id like spaces between them of 10px, when those margins are added with the code below, they don't align, please also see jfiddle.
http://jsfiddle.net/b0rrz8bg/
CSS
.new-agency-clients{
position: relative;
border-radius:6px;
background:#fcfbfc !important;
background:-webkit-gradient(linear,left top,left bottom,from(#fcfbfc),to(#f7f6f7)) !important;
background:-webkit-linear-gradient(#fcfbfc,#f7f6f7) !important;
background:-moz-linear-gradient(center top,#fcfbfc 0,#f7f6f7 100%) !important;
background:-moz-gradient(center top,#fcfbfc 0,#f7f6f7 100%) !important;
width:940px;
height: 100%;
box-shadow:0 0 3px #444;
-moz-box-shadow:0 0 3px #444;
-webkit-box-shadow:0 0 3px #444;
padding-top: 10px;
margin-top:10px;
margin-bottom:10px;
}
.new-agency-clients-box {
overflow:hidden;
}
.new-agency-clients-box .entry-profile {
bottom:0;
top:0;
left:0;
right:0;
margin-left:10px;
margin-bottom: 10px;
float:left;
position:relative;
width: 225px;
height: 270px;
background: #ffffff;
border-radius: 6px;
overflow:hidden;
box-shadow:0 0 3px #444;
-moz-box-shadow:0 0 3px #444;
-webkit-box-shadow:0 0 3px #444;
}
.new-agency-clients-box .entry-profile .profilename {
margin-top: -35px;
line-height: 26px;
height: 28px;
width: 100%;
background:#cccccc;
background:-webkit-gradient(linear,left top,left bottom,from(#eeeeee),to(#cccccc)); background:-webkit-linear-gradient(#eeeeee,#cccccc);
background:-moz-linear-gradient(center top,#eeeeee 0,#cccccc 100%);
background:-moz-gradient(center top,#eeeeee 0,#cccccc 100%);
color: #444;
display: block;
font-size: 14px;
font-weight: bold;
position: relative;
border-radius: 0px !important;
}
.new-agency-clients-box .entry-profile .profile-box-image{
background: #0e0e0e !important;
width: 225px;
height: 270px;
margin-bottom: 10px;
cursor: pointer;
position: relative;
}
.new-agency-clients-box .entry-profile .profile-box-image:hover{
filter: alpha(opacity=60,Style=0);
opacity: 0.6;
cursor: pointer;
}
.new-agency-clients-box .entry-profile .profile-box-image a img{
width: 225px;
height: 270px;
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.new-agency-clients-box .entry-profile .profile-box-image a img.default{
width: 225px;
height: auto;
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
#media only screen and (max-width: 750px) {
.wrap {width: auto;}
.new-agency-clients {width: 100%;}
.new-agency-clients-box .entry-profile {width: 50%; height: 50%;}
}
HTML
<div class="new-agency-clients">
<div class="new-agency-clients-box">
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6>Profile</h6>
</div>
</center>
</div>
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6>Profile</h6>
</div>
</center>
</div>
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6>Profile</h6>
</div>
</center>
</div>
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6>Profile</h6>
</div>
</center>
</div>
</div>
</div>
While your approach to responsive layouts leaves a lot to discuss, in your specific case just do this:
#media only screen and (max-width: 750px) {
.wrap {width: auto;}
.new-agency-clients {width: 100%;}
.new-agency-clients-box .entry-profile {width: calc( 50% - 10px ) ; height: auto}
}
CSS margins are working correctly, but if you have 50%+10px, then it's obvious the element will take 50%+, thus wrapping to next line. Therefore, we use calc to make those elements 50% MINUS the margin you want and voilá, it works like magic. I have forked your fiddle so you can play around
EDIT: Including new code as per comment
Change this HTML
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
to this (we're removing the width and height from markup, which, anyways, you shouldn't use):
<img src="" class="attachment-post-thumbnail wp-post-image" alt="" />
Now, in your CSS, it's as easy as this:
.entry-profile .wp-post-image{width:100%; height:auto; max-width:700px;}
See that we could also use width:auto; height:100%; max-height:875px and also restrict the min height or width like this width:auto; height:100%; max-height:875px; min-height:200px /* or restrict the width if you want */ . All approaches, while relatively similar, have different behaviors on resizing, but all of them are responsive, so test them with your code and see which one you prefer for your project.
Use one and resize and see how the element behaves and you'll understand how easy it is, which is nothing but, for example "the image will take 100% of the containing element, adjusting automatically to a maximum width of 700px and a minimum width of 200px "
All this being said, which is basic theory, see you'll probably prefer in most cases to apply max and min width to the containing element, so your CSS will slightly change and everything will be even easier
.entry-profile{width: calc( 25% - 10px ) /* 4 columns! */ ; max-width:700px; min-width:200px}
.entry-profile .wp-post-image{width:100%; height:auto; /* responsive scalable images no matter the size of container */}
So i have an image, I have a text box with a transparent background that is overlaid on the image (FYI it contains the price of the item and if it is onsale).
I would like the text box to "fit" the width of the image it is over.
Currently the text is wider than the image. I've tried adjusting the width but that only seems to shrink it and move the box out from being over the image.
http://jsfiddle.net/Ggqy4/
Here is what I'm aiming to create. Notice the text is only as wide as the image.
http://imgur.com/zKzjIyF
The red box inside the box is on the first item on the left, the girl in the vest.
HTML:
<div class="date-container">
<div class="date-heading" style="display: block;">Friday, Oct 11, 2013</div>
<div class="items-purchased-container">
<DIV style="position: absolute; top:10px; left:355px; width:200px; height:25px">3</span> items purchased</p>
</div>
<div class="total-spend-container">
<div class="product">
<img src="https://theory.alluringlogic.com/api/v1/productvariation/3/1058.jpg?preset=XS" alt="" />
<div class="description">
<p>Sex shirt in sparkly black <span class="price">Price $500</span>
</p>
</div>
</div>
<div class="product">
<img src="https://theory.alluringlogic.com/api/v1/productvariation/3/1058.jpg?preset=XS" alt="" />
<div class="description">
<p>Sex shirt in sparkly black <span class="price sale">Sale Price $500</span>
</p>
</div>
</div>
CSS:
body {
background:#00000;
text-align:center;
}
.product {
display:inline-block;
position:relative;
margin-right:10px;
vertical-align:top;
}
.product img {
display:block;
max-width:100%;
}
.description {
position:absolute;
background:rgba(255, 255, 255, 0.75);
top:60%;
;
text-align:center;
width:100%;
}
.description span {
display:block;
margin-top:10px;
padding:5px;
}
.sale {
background:red;
}
Here is a JSFiddle file for your review: CLICK HERE
As mentioned above by Giovanni Silveira, your images contain a large left/right border. You can either crop in your favorite image editor or you will have to manipulate your code to accommodate the added area to your liking.
I did add some changes to force the appearance you were looking for, however if you want a less intrusive set up then it would be prudent to change you images to fit your needs.
To view how the page was set up, just add
border: 1px solid #ccc;
to your product and description classes to see the flow and gain a better understanding of the images impact on flow of document.
Hope this helps.
Here is the code:
HTML:
<div class="orderinfo">
<div class="date">Friday, Oct 11, 2013</div>
<div class="purchaseitems">3 items purchased</div>
</div>
<div class="total-spend-container">
<div class="product">
<img src="https://theory.alluringlogic.com/api/v1/productvariation/3/1058.jpg?preset=XS" style="width:300px;height:250px" alt="" />
<div class="description">
<p>Sex shirt in
<br>sparkly black</br> <span class="price">Price $500</span>
</p>
</div>
</div>
<div class="product">
<img src="https://theory.alluringlogic.com/api/v1/productvariation/3/1058.jpg?preset=XS" style="width:300px;height:250px" alt="" />
<div class="description">
<p>Sex shirt in
<br>sparkly black</br> <span class="price sale">Sale Price $500</span>
</p>
</div>
</div>
CSS:
body {
background: #00000;
text-align: center;
}
.orderinfo {
position: relative;
width: 100%;
min-width: 650px;
font-family: "Courier", sans-serif;
font-size: 20px;
}
.date, .purchaseitems {
float: left;
width: 49%;
padding-bottom: 10px;
}
.total-spend-container {
min-width: 650px;
}
.product {
position: relative;
display: inline-block;
width: 300px;
height: 250px;
}
.product img {
background-position: center;
background-size: cover;
}
.description {
position: absolute;
background: rgba(255, 255, 255, 0.75);
font-family: "Courier", sans-serif;
font-style: italic;
top: 50%;
text-align: center;
left: 25%;
width: 50%;
}
.description span {
display: inline-block;
margin-top: 10px;
padding: 3px;
}
.sale {
background: red;
color: white;
}