Currently, I am attempting to create a dock (similar to the iOS dock) for my website. Below is the full code that I have implemented:
function addPrevClass(e) {
var target = e.target;
if (target.getAttribute('src')) { // check if it is img
var li = target.parentNode.parentNode;
var prevLi = li.previousElementSibling;
if (prevLi) {
prevLi.className = 'prev';
}
target.addEventListener('mouseout', function() {
prevLi.removeAttribute('class');
}, false);
}
}
if (window.addEventListener) {
document.getElementById("dock").addEventListener('mouseover', addPrevClass, false);
}
li {
float: left;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(255, 255, 255, 0.05);
}
#dock li img {
width: 64px;
height: 64px;
-webkit-box-reflect: below 2px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.7, transparent), to(rgba(255, 255, 255, .5)));
/* reflection is supported by webkit only */
-webkit-transition: all 0.3s;
-webkit-transform-origin: 50% 100%;
}
#dock li:hover img {
-webkit-transform: scale(2);
margin: 0 2em;
}
#dock li:hover + li img,
#dock li.prev img {
-webkit-transform: scale(1.5);
margin: 0 1.5em;
}
#dock-container ul {
text-align: center;
}
<div id="dock-container">
<div id="dock">
<ul>
<li>
<a href="http://android.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
<li>
<a href="http://palm.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
<li>
<a href="http://android.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
<li>
<a href="http://palm.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
<li>
<a href="http://android.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
<li>
<a href="http://palm.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
<li>
<a href="http://android.com">
<img src="https://dl.dropboxusercontent.com/u/1330446/demo/dock/images/dock-icons/palm.png" />
</a>
</li>
</ul>
<div class="base"></div>
</div>
</div>
However, I am facing an issue with the alignment of my dock on the website. Removing the "float: left;" property results in a vertical orientation of the dock. How can I center the dock while keeping it horizontal? Any suggestions or solutions would be greatly appreciated.