html/css help
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

[Closed] html/css help

10 Posts
5 Users
0 Reactions
45 Views
Posts: 0
Free Member
Topic starter
 

.img1container {
position: absolute;
left: 16mm;
top:58mm;
width: 387mm;
height: 180mm;
z-index: 2;
overflow: hidden;
text-align:center;

}

.img1container img {
width: 100%;
}

<div class="img1container">
<imgsrc="[[Image1]]" contenteditable="true" />
</div>

How to I get the image to centre vertically, ie to overflow top and bottom, instead of just overflowing to the bottom?


 
Posted : 28/03/2018 1:06 pm
Posts: 0
Free Member
 

Take your pick from CSS Tricks It's a good site to bookmark for CSS stuff anyway


 
Posted : 28/03/2018 1:17 pm
Posts: 0
Free Member
Topic starter
 

will try ta.


 
Posted : 28/03/2018 1:46 pm
Posts: 10315
Full Member
 

I can't believe you asked that on here. Well done 🙂


 
Posted : 28/03/2018 1:47 pm
Posts: 10315
Full Member
 

And more usefully, my memory is you need a vertical-align and an inline block somewhere but I can't exactly remember where. I'll Jose when I get home


 
Posted : 28/03/2018 1:50 pm
Posts: 40225
Free Member
 

I can’t believe you asked that on here. Well done

Ah, but we have no idea what he really asked.


 
Posted : 28/03/2018 2:25 pm
Posts: 0
Free Member
Topic starter
 

sorted, got it. 🙂

.img1container {
position: absolute;
left: 16mm;
top:58mm;
width: 387mm;
height: 180mm;
z-index: 2;
overflow: hidden;
}

.img1container img {
width: 100%;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}

centres top/bottom, left/right;


 
Posted : 28/03/2018 3:10 pm
Posts: 0
Free Member
Topic starter
 

Next question, that's fine I now have a choice of fit width or fit height, and it'll centre, horizontally and vertically and clip the overlay.

How do I get it to auto fill by height or width, and the proportion of the images is likely to be variable. So that is more desirable than having to make the decision as to to width: 100%; or height: 100%;


 
Posted : 28/03/2018 3:21 pm
Posts: 0
Free Member
Topic starter
 

I can’t believe you asked that on here. Well done

is that good or bad? 😀


 
Posted : 28/03/2018 3:25 pm
Posts: 0
Free Member
 

Does it have to be an IMG inside the DIV? You could set the DIV's background to the image source, then use the following CSS:

background-position: center;

background-repeat: no-repeat;

background-size: cover;


 
Posted : 28/03/2018 3:46 pm
Posts: 0
Free Member
Topic starter
 

ah, doesn't work in the pdf generation bit, bugger.

Will have a go at the background image thing. ta.


 
Posted : 28/03/2018 3:57 pm

6 DAYS LEFT
We are currently at 95% of our target!