How to prevent an image's margin from being clickable? - html

How can I remove the image's margin from the clickable region, without interfering in the layout of the page?
#logo{
width: auto;
min-height: 80px;
margin: 30px;
height: auto;
box-sizing: border-box;
text-aligh:center;
}
.img1 {
width: 200px;
height: 105px;
}
.img2 {
width: 200px;
height: 105px;
margin-left: 15px;
}
.img3 {
width: 200px;
height: 105px;
margin-left: 15px;
}
<div id="logo"><img class="img1" src="Photos/m.png"/>
<img class="img2"src="Photos/u.png" alt="U"/>
<img class="img3" src="Photos/p.png" alt="P"/>
</div>
15px on the lower left site img2 and img3 can be clicked.

Put the margin to the A tag instead of IMG:
#logo{
width: auto;
min-height: 80px;
margin: 30px;
height: auto;
box-sizing: border-box;
text-align:center;
}
.img1 {
width: 200px;
height: 105px;
}
.img2 {
width: 200px;
height: 105px;
}
.a2, .a3 {
margin-left: 15px;
}
.img3 {
width: 200px;
height: 105px;
}
<div id="logo"><img class="img1" src="Photos/m.png"/>
<a class="a2" href="U"><img class="img2"src="Photos/u.png" alt="U"/></a>
<a class="a3" href="/#"><img class="img3" src="Photos/p.png" alt="P"/></a>
</div>

This simplifies your CSS declarations a bit too. In lieu of setting the margin as you had it, this sets it on <a> elements.
#logo{
width: auto;
min-height: 80px;
margin: 30px;
height: auto;
box-sizing: border-box;
text-aligh:center;
}
.img {
width: 200px;
height: 105px;
}
a:not(:first-of-type) {
margin-left: 15px;
}
<div id="logo">
<img class="img" src="Photos/m.png"/>
<img class="img"src="Photos/u.png" alt="U"/>
<img class="img" src="Photos/p.png" alt="P"/>
</div>

Related

img positioning inside div container

Can't get img inside "head-logo" div to center both vertically amd horizontaly.
i tryed CSS solutions like:
1)
.head-logo img {
margin-left: auto;
margin-right: auto;
display: block;
}
2)
.head-logo img {
vertical-align: middle;
}
3)
.head-logo img {
display: -webkit-flex;
display: -ms-flex;
display: flex;
justify-content: center;
-ms-align-items: center;
align-items: center;
}
etc
<div class="head-container">
<div class="head-logo">
<img src="img\logo.svg" height="70" width="70">
</div>
<div class="head-menu">
</div>
</div>
div {
border: dotted 1px;
}
.head-container {
width: 80%;
height: 100px;
margin: auto;
padding: 5px;
background-color: aqua;
}
.head-logo {
vertical-align: middle;
width: auto;
height: 100px;
background-color: red;
float: left;
}
.head-logo img {
}
Current result is img is stuck to upper left corner of parent div, and I need it centered from all sides.
Probably I'm missing something, quite new to css, looking forward for your help.
div {
border: dotted 1px;
}
.head-container {
width: 80%;
height: 100px;
margin: auto;
padding: 5px;
background-color: aqua;
}
.head-logo {
vertical-align: middle;
width: auto;
height: 100px;
background-color: red;
float: left;
}
.head-logo img {
}
<div class="head-container">
<div class="head-logo">
<img src="https://via.placeholder.com/150x200/O%20https://placeholder.com/" height="70" width="70">
</div>
<div class="head-menu">
</div>
</div>
There is few ways of doing it. My preferred one is this
div {
border: dotted 1px;
}
.head-container {
width: 80%;
height: 100px;
margin: auto;
padding: 5px;
background-color: aqua;
}
.head-logo {
width: 100px;
height: 100px;
background-color: red;
float: left;
overflow: hidden;
position: relative;
}
.head-logo img {
position: absolute;
width: 100%;
height: auto;
top: -50%;
right: -50%;
bottom: -50%;
left: -50%;
margin: auto;
}
<div class="head-container">
<div class="head-logo">
<img src="https://placeholder.com/wp-content/uploads/2018/10/placeholder.com-logo1.png" height="70" width="70">
</div>
<div class="head-menu">
</div>
</div>
Benefits of this solution is that it will always stay at center of parent container it works well in older versions of browsers u can set img width to fixed like "100px" if u want to logo stay at same size or set it to scale to parent container
overflow: hidden; in parent container make sure that bigger picture will not spill out off container
div{
height: 300px;
width: 300px;
padding: 10%;
background: red;
box-sizing: border-box;
}
div img{
height: 100%;
width: 100%;
}
<div>
<img src="https://media.gettyimages.com/photos/trent-boult-of-new-zealand-bowls-during-day-two-of-the-second-test-picture-id1087035928" alt="">
</div>
You could try object-fit - like:
.head-logo img {
object-fit: contain;
height: 100%;
}
Object-fit demo (including image polyfill for ie) https://codepen.io/jakob-e/pen/Pxwzpw
/* object fit polyfill */
// is object fit supported
if (document.body.style.objectFit === undefined) {
// loop through all images
[].slice
.call(document.querySelectorAll('img'))
.map(function (img) {
// image has background-size cover or contain
if (['cover', 'contain']
.indexOf(getComputedStyle(img).backgroundSize) !== -1) {
// use src as background image
img.style.backgroundImage = "url(" + img.src + ")";
// replace src with transparent gif
img.src = 'data:;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
}
});
}
/* add this */
.head-logo img {
height: 100%;
object-fit: contain;
background-size: contain; /* used by polyfill */
background-repeat: no-repeat; /* used by polyfill */
}
div {
border: dotted 1px;
}
.head-container {
width: 80%;
height: 100px;
margin: auto;
padding: 5px;
background-color: aqua;
}
.head-logo {
vertical-align: middle;
width: auto;
height: 100px;
background-color: red;
float: left;
}
<div class="head-container">
<div class="head-logo">
<img src="https://i.pinimg.com/originals/33/b8/69/33b869f90619e81763dbf1fccc896d8d.jpg" height="70" width="70">
</div>
<div class="head-menu">
</div>
</div>
Try this: (ignore long image link :p)
div {
border: dotted 1px;
}
.head-container {
width: 80%;
height: 100px;
margin: auto;
padding: 5px;
background-color: aqua;
}
.head-logo {
width: 150px;
height: 100px;
background-color: red;
float: left;
display: flex;
justify-content: center;
}
.head-logo img {
display: block;
margin: auto;
vertical-align: middle;
}
<div class="head-container">
<div class="head-logo">
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUTExMWFhUWGBgaGBgYFxcXGhcaFRgWFxYYGhcYHSggGBolHRcYITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGy0lICUtLS0tLS8vLS0tLS0tLy0tLS8tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAKgBLAMBIgACEQEDEQH/xAAcAAACAgMBAQAAAAAAAAAAAAAEBQMGAAIHAQj/xAA7EAABAwMDAgUCAwcEAgIDAAABAgMRAAQhBRIxQVEGEyJhcYGRMkKhBxQjscHR8FJi4fEVM2NyCBZD/8QAGQEAAwEBAQAAAAAAAAAAAAAA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Aml1hpaFp3KGZ7jsP61Yb+6aS2UwFEkEEE59vg5oMMrPx0wOOlKVyFqGrxy8rBE81C2wa9rKjB1IhNWbaCfvnOfrWydPChkY6AY/XrXtZXiTMJh1nbQNvT9OAPvApmpICY/z2NZWVhmAxY88Aoxx/k1u26lcScj9R2rysoSIJElvrxBGECZyR9qW27hQNogBRVIA5EjJ98YrKyvKKngajNi4wACRAxGT8zijWEpGZk/zPU1lZRWYxXIh9vdbDvQ5tMciJjsJ4rd3WZxtgTuiIg8YnocfrXtZRLkYaBlCeVkVSFNX3BLbXykny0gT+Ic5kwdx7j+VBX7y3F7du0HhU/H1H9a9rK31GGoAc1XxPLIJ3LH4gFGPfpOKs1jcAncPb9Kysr1XOp4x6k92wCJ60LcIgATWVlJfqNy7m11a728n0jMd4IxSx+SIkAdE9vtWVlbgOpKchU0JFpjwCiFnAOP8Ag0bfFboIkhI4jj5xWVldBzS3GZGpbgFrpydplcn4rRTygIMx3rKyosrkkTm53OiI10bUg2SRwecfejtU1FDowAZ/SsrK0ZWOpTj8rIQFO4Oy6iOBVe8R6eHxAMc+1ZWU1shqdHNnPpHQle/8CC2ESSEgDPXndPseI961YB9TZEiUz79yfevaylLkY3c4mPIxsSC0sIDi4MFwr+iwEkH9aLtdP9AIACwuSY5wBHxisrKMuY0MQajpy1SIVtEgfQH2FBN2aQkgZCp7cn+lZWUiz3J3YhtQFOmAmSBj27VE8xnAxXtZRWT3BBJn/9k=" height="70" width="120">
</div>
<div class="head-menu">
</div>
</div>

why margin does not work with component even defined with relative position

My code is as shown below:
xyz.html
<div class='main-container'>
<div class="q-background">
</div>
<div class="q-text">
<div>Order History</div>
</div>
<div class ="q-orders">
</div>
</div>
xyz.scss
.main-container {
height: 100vh;
width: 100vw;
margin-top: -4rem;
.q-background {
float: left;
width: 100%;
height: 14.3vw;
background: url("../../image/i-header-list.jpg") no-repeat;
background-size: contain;
}
.q-text {
position: relative;
margin-top: 1rem;
font-size: 2rem;
text-align: center;
}
.q-orders {
position: relative;
margin-left: 2rem;
float: left;
height: 50%;
width: 50%;
background-color: #ff3;
}
}
now what happens here is margin-top:1rem does not work for q-text even after defining position:relative. So is there anything missing?
The margin-top is working on .q-text, but you set on the parent a margin-top:-4rem. You should avoid a negative value on margin.
.main-container {
height: 100vh;
width: 100vw;
}
.main-container .q-background {
float: left;
width: 100%;
height: 14.3vw;
background: url("../../image/i-header-list.jpg") no-repeat;
background-size: contain;
}
.main-container .q-text {
position: relative;
margin-top: 1rem;
font-size: 2rem;
text-align: center;
top:0;
}
.main-container .q-orders {
position: relative;
margin-left: 2rem;
float: left;
height: 50%;
width: 50%;
background-color: #ff3;
}
<div class='main-container'>
<div class="q-background">
</div>
<div class="q-text">
<div>Order History</div>
</div>
<div class ="q-orders">
</div>
</div>

Auto fit image in DIV is not working in bloger

I have written the following code to auto fit image in DIV. It is perfectly working in JSFIDDLE but not working in my blog http://roadroute.blogspot.in/2015/08/flipkart.html
Please find the code below
.responsive-container1 {
position: relative;
width: 250px;
height: 415px;
border: 1px solid red;
margin-right: 10px;
margin-top:10px;
float: left;
}
.dummy {
padding-top: 100%; /* forces 1:1 aspect ratio */
}
.img-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align:center; /* Align center inline elements */
font: 0/0 a;
}
.img-container:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
}
.img-container img {
max-width: 100%;
max-height: 100%;
margin: auto;
vertical-align: middle;
display: inline-block;
}
<div class="responsive-container1">
<div class="dummy"></div>
<div class="img-container">
<img src="https://googledrive.com/host/0BxPZgr7ebTBdTkowMFVRTDJTS00/01.jpg" alt="" />
</div>
</div>
<div class="responsive-container1">
<div class="dummy"></div>
<div class="img-container">
<img src="https://googledrive.com/host/0BxPZgr7ebTBdTkowMFVRTDJTS00/02.png" alt="" />
</div>
</div>
<div class="responsive-container1">
<div class="dummy"></div>
<div class="img-container">
<img src="https://googledrive.com/host/0BxPZgr7ebTBdTkowMFVRTDJTS00/03.jpg" alt="" />
</div>
</div>
Please help.
just add
width:100%; height:100%;
in your image container class.
.responsive-container1 {
position: relative;
width: 250px;
height: 415px;
border: 1px solid red;
margin-right: 10px;
margin-top:10px;
float: left;
}
.dummy {
padding-top: 100%;
max-width:100%;
max-height:100%; /* forces 1:1 aspect ratio */
}
.img-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align:center; /* Align center inline elements */
font: 0/0 a;
max-width:100%;
max-height:100%;
}
.img-container:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
max-width:100%;
max-height:100%;
}
.img-container img {
width: 100%;
height: 100%;
margin: auto;
vertical-align: middle;
display: inline-block;
}
<div class="responsive-container1">
<div class="dummy"></div>
<div class="img-container">
<img src="https://googledrive.com/host/0BxPZgr7ebTBdTkowMFVRTDJTS00/01.jpg" alt=""/>
</div>
</div>
<div class="responsive-container1">
<div class="dummy"></div>
<div class="img-container">
<img src="https://googledrive.com/host/0BxPZgr7ebTBdTkowMFVRTDJTS00/02.png" alt="" />
</div>
</div>
<div class="responsive-container1">
<div class="dummy"></div>
<div class="img-container">
<img src="https://googledrive.com/host/0BxPZgr7ebTBdTkowMFVRTDJTS00/03.jpg" alt="" />
</div>
</div>
You should remove following css:
.dummy {
padding-top: 100%;
}
.img-container {
bottom: 0;
font: 0px/0 a;
left: 0;
position: absolute;
right: 0;
text-align: center;
top: 0;
}
And .post-body img have have padding: 8px; will put/display your image outside div. Either remove that Or make image max-width: 90%;.
It will wok for you.
Edit:
Give: text-align:center to .responsive-container1.
.responsive-container1 {
border: 1px solid red;
float: left;
height: 415px;
margin-right: 10px;
margin-top: 10px;
position: relative;
text-align: center;
width: 250px;
}
And max width and height 90% and give position and top value And also give transform.
.post-body img {
background: #222222 none repeat scroll 0 0;
border: 1px solid transparent;
border-radius: 0;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.2);
max-height: 90%;
max-width: 90%;
padding: 8px;
position: relative;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
}
It will do the trick.

Can't center images in div

So I have a div, inside that i have horizontally aligned divs, in this example just 1. Within this horizontal div are 3 divs, one aligned to the left, one middle and one right. I want the images within each of those 3 divs to be centered so it is more visually appealing.
I have tried: margin: 0 auto; but it didn't work, any ideas why this isn't working and how to get it working?
HTML
<div id="main">
<div id="firstRow">
<div class="firEl">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p>BlahBlahBlah</p>
</div>
<div class="secEl">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p class="elPara">BlahBlahBlahBlahBlah</p>
</div>
<div class="thirEl">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p class="elPara">BlahBlahBlahBlahBlah</p>
</div>
</div>
CSS
.logo{
width: 100px;
height: 100px;
margin:0 auto;
}
#main{
width: 650px;
height:650px;
margin: 0 0 1em 0;
overflow: auto;
min-width: 650px;
width: 50%;
margin: 0 auto;
background-color:#fff;
}
#firstRow{
width:650px;
min-width:650px;
width: 50%;
margin: 0 auto;
background-color:#CCC;
overflow:hidden;
}
.firEl{
background-color: #FFF;
min-width: 10px;
height: 140px;
width: 100px;
width: 30%;
float:left;
margin: 10px;
}
.secEl{
background-color: #FFF;
min-width: 10px;
height: 140px;
width: 100px;
width: 30%;
margin: 10px;
float:left;
}
.thirEl{
background-color: #FFF;
min-width: 10px;
width: 100px;
height: 140px;
width: 30%;
margin: 10px;
float:left;
}
http://jsfiddle.net/genome314/2u695mdu/
Adding this should do the trick:
img {
display: block;
margin: 0 auto;
}
Or just align center as the other answer below stated, if you want to keep your images inline.
set text-align:center for each div that contains the logo.
#firstRow div{
text-align:center;
}
I threw in Nick Solloum's answer and found that the logos were still a little off center towards the bottom. I made all your image classes into one since they had the same values anyway. I fixed this by changing padding-top: to 4% and found it looked much cleaner to me. Here is the adjusted CSS. I hope this helps
HTML
<html>
<body>
<link rel="stylesheet" type="text/css" href='so.css'>
</body>
<div id="main">
<div id="firstRow">
<div class="El">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p>BlahBlahBlah</p>
</div>
<div class="El">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p class="elPara">BlahBlahBlahBlahBlah</p>
</div>
<div class="El">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p class="elPara">BlahBlahBlahBlahBlah</p>
</div>
</div>
</html>
CSS
.logo{
width: 100px;
height: 100px;
margin:0 auto;
}
#main{
width: 650px;
height:650px;
margin: 0 0 1em 0;
overflow: auto;
min-width: 650px;
width: 50%;
margin: 0 auto;
background-color:#fff;
}
#firstRow{
width:650px;
min-width:650px;
width: 50%;
margin: 0 auto;
background-color:#CCC;
overflow:hidden;
}
.El{
background-color: #FFF;
min-width: 10px;
width: 100px;
height: 140px;
width: 30%;
margin: 10px;
float:left;
padding-top: 4%;
}
img {
display: block;
margin: 0 auto;
}
Give text-align:center; in each div css
like:
.firEl{
text-align:center;
}
Edit
if, text don't want center then:
.elPara{
text-align:left;
}
Check your updated code here. Fiddle
Method 1
Add display block to .logo. Check here: http://jsfiddle.net/2u695mdu/4/
CSS
.logo{
width: 100px;
height: 100px;
display: block;
margin-left: auto;
margin-right: auto;
}
#main{
width: 650px;
height:650px;
margin: 0 0 1em 0;
overflow: auto;
min-width: 650px;
width: 50%;
margin: 0 auto;
background-color:#fff;
}
#firstRow{
width:650px;
min-width:650px;
width: 50%;
margin: 0 auto;
background-color:#CCC;
overflow:hidden;
}
.firEl{
background-color: #FFF;
min-width: 10px;
height: 140px;
width: 100px;
width: 30%;
float:left;
margin: 10px;
}
.secEl{
background-color: #FFF;
min-width: 10px;
height: 140px;
width: 100px;
width: 30%;
margin: 10px;
float:left;
}
.thirEl{
background-color: #FFF;
min-width: 10px;
width: 100px;
height: 140px;
width: 30%;
margin: 10px;
float:left;
}
HTML
<div id="main">
<div id="firstRow">
<div class="firEl">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p>BlahBlahBlah</p>
</div>
<div class="secEl">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p class="elPara">BlahBlahBlahBlahBlah</p>
</div>
<div class="thirEl">
<img class="logo" src="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg"></img>
<p class="elPara">BlahBlahBlahBlahBlah</p>
</div>
</div>
</div>
Only the image is centered.
Method 2
Add <div align="center"> before each image, as here: http://jsfiddle.net/2u695mdu/7/
Method 3
Check #ketan answer.
Method 4
Because you setted the image width, you can use, postion relative to images as here http://jsfiddle.net/2u695mdu/8/
.logo{
width: 100px;
height: 100px;
position: relative;
left: 50%;
margin-left: -50px;
}
display: block;
margin: auto;
instead of
margin:0 auto;

Height of a DIV-container

I've got a problem with DIV-containers.
.inner-teaser {
width: 100%;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
.bg-blue {
background: blue;
}
.teaser-image {
background-position: center;
background-size: 350px;
width: 250px;
height: 250px;
border-radius: 150px;
}
.image-left {
float: left;
margin-right: 50px;
}
<div class="outer-teaser bg-blue">
<div class="inner-teaser">
<div class="teaser-image image-left" style="background-image: url(http://lorempixel.com/output/abstract-q-c-640-480-5.jpg);">Image</div>
<div class="teaser-text">Lorem ipsum dolor...</div>
</div>
</div>
The inner-teaser should have the height from the teaser-image (250px) + 20px padding. But inner-teaser has only a height of 40px (2 * 20px padding).
Add overflow: hidden to .inner-teaser to force it to take its floating-children height:
.inner-teaser {
width: 100%;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
overflow: hidden;
}
.bg-blue {
background: blue;
}
.teaser-image {
background-position: center;
background-size: 350px;
width: 250px;
height: 250px;
border-radius: 150px;
}
.image-left {
float: left;
margin-right: 50px;
}
<div class="outer-teaser bg-blue">
<div class="inner-teaser">
<div class="teaser-image image-left" style="background-image: url(http://lorempixel.com/output/abstract-q-c-640-480-5.jpg);">Image</div>
<div class="teaser-text">Lorem ipsum dolor...</div>
</div>
</div>
You can also use { display: inline-block } for .inner-teaser div.
.inner-teaser {
width: 100%;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
display: inline-block;
}
.bg-blue {
background: blue;
}
.teaser-image {
background-position: center;
background-size: 350px;
width: 250px;
height: 250px;
border-radius: 150px;
}
.image-left {
float: left;
margin-right: 50px;
}
<div class="outer-teaser bg-blue">
<div class="inner-teaser">
<div class="teaser-image image-left" style="background-image: url(http://lorempixel.com/output/abstract-q-c-640-480-5.jpg);">Image</div>
<div class="teaser-text">Lorem ipsum dolor...</div>
</div>
</div>
just add after class class="teaser-text" see demo :demo
.inner-teaser {
width: 100%;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
.bg-blue {
background: blue;
}
.teaser-image {
background-position: center;
background-size: 350px;
width: 250px;
height: 250px;
border-radius: 150px;
}
.image-left {
float: left;
margin-right: 50px;
}
<div class="outer-teaser bg-blue">
<div class="inner-teaser">
<div class="teaser-image image-left" style="background-image: url(http://lorempixel.com/output/abstract-q-c-640-480-5.jpg);">Image</div>
<div class="teaser-text">Lorem ipsum dolor...</div>
<div style="clear:both"></div>
</div>
</div>
v style="clear:both">