I am having problems positioning an image wrapped in a link.
here is the html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Albums</title
<link rel="stylesheet" type="text/css" href="../../css/BackButton.css" />
<link rel="stylesheet" type="text/css" href="MotusStyles.css" />
</head>
<body>
<article>
<div id="container">
<div id="albumSky" class="albums">
<img src="../Images_Albums/PortadaMotus.jpg">
</div>
<div id="songs">
<p>01 song</p>
<p>02 song</p>
<p>03 song</p>
<p>04 song</p>
<p>05 song</p>
<p>06 song</p>
<p>07 song</p>
<p>08 song</p>
<p>09 song</p>
<p>10 song</p>
</div>
<div id="order">
<a href="https://itunes.apple.com/gb/album/motus-et-bouche-cousue/id595359048?app=music&ign-mpt=uo%3D4"><img id="icon" src="apple.svg"></a>
</div>
</div>
<div id="credits">
<p>someone, voc, piano / someone, bss</p>
</div>
</article>
<div id="info">
<a href="../index.html"><p class="backContact">[back]</p></a>
</div>
</body>
</html>
css
@font-face {font-family: QuaestorSans;
src: url("../fonts/QuaestorSans-Rg.otf") format("opentype"),
url("../fonts/QuaestorSans.ttf") format("opentype");
}
html, body {
height: 100%;
margin:0;
padding:0;
}
body {
background: url(../Images_Albums/FondBack.jpg) no-repeat;
background-size: 100%;
/* background-color: red;*/
}
article {
position: absolute;
width: 32%;
height: 100%;
left: 50%;
transform: translate(-50%, 0);
background: url(../Images_Albums/FondFront.jpg) no-repeat;
background-size: 100%;
}
#container {
margin-top: 9%;
position: absolute;
width: 50%;
left: 50%;
transform: translate(-50%, 0);
background-color: green;
}
img {
width: 100%;
display: block;
margin-bottom: 15%;
}
a {
text-decoration: none;
}
#songs {
position: relative;
height: 185px;
overflow: scroll;
overflow-x:hidden;
width:80%;
left: 50%;
transform: translate(-50%, 0);
}
#songs p {
margin: 0;
margin-bottom: 7%;
color: white;
font-family: QuaestorSans;
font-size: 1em;
line-height: 1.3;
width: 100%;
}
/* SCROLLBAR */
#songs::-webkit-scrollbar {
width: 7px;
}
/* Track */
#songs::-webkit-scrollbar-track {
background: #8fdcf6;
border: 3px solid transparent;
background-clip: content-box;
}
/* Handle */
#songs::-webkit-scrollbar-thumb {
background: #c7edfa;
border-radius:10px;
}
#songs::-webkit-scrollbar-thumb:hover{
background-color:#c7edfa;
border:1px solid #333333;
}
#songs::-webkit-scrollbar-thumb:active{
background-color:#c7edfa;
border:1px solid #333333;
}
#order {
margin-top: 20%;
position: relative;
font-family: QuaestorSans;
font-size: 1.2em;
text-align: center;
width: 100%;
height: 50px;
background-color: red;
}
#icon {
width: 60%;
}
/*#order a {
display:block;
left: 50%;
overflow:hidden;
background: url(apple.svg) no-repeat;
background-color: red;
background-position: center;
width:132px;
height:48px;
background-size:contain;
}*/
#credits {
margin-top: 135%;
width: 65%;
position: absolute;
font-family: QuaestorSans;
font-size: 1em;
line-height: 1.3;
margin-bottom: 1%;
left: 50%;
transform: translate(-50%, 0);
}
#credits p{
margin: 0;
line-height: 1.5;
color: #6ec7e9;
}
.backContact {
color: #639cad;
}
.backContact:hover {
color: #c7ecff;
}
That doesn't work. The image refuses to be placed in the center and just stays positioned to the left (see image: i have set background colours to make sure the element spans over the 100% of the width of the parent element).
I have also tried:
#order a {left:50%;
transform: translate(-50%, 0);
}
Image:
I want the iTunes logo in the middle.
Just Remove below your css rules.