I'm trying to display the arrows and images on the same line. How do I achieve that? (I'm using html5boilerplate).

What I need:

enter image description here

What I have now:

enter image description here

Current code:

HTML:

    <div id="linkbar">
        <a><img src="./img/arrowleft.png"></a>
        <div id="linkbarinternal">
            <ul>
                <li><a><img src="./img/banner01.jpg"></a></li>
                <li><a><img src="./img/banner02.jpg"></a></li>
                <li><a><img src="./img/banner03.jpg"></a></li>
                <li><a><img src="./img/banner04.jpg"></a></li>
                <li><a><img src="./img/banner05.jpg"></a></li>
                <li><a><img src="./img/banner06.jpg"></a></li>
                <li><a><img src="./img/banner07.jpg"></a></li>
                <li><a><img src="./img/banner08.jpg"></a></li>
            </ul>
        </div>
        <a><img src="./img/arrowright.png"></a>
    </div>

CSS:

#linkbar {
    width:90%;
    margin-left: auto;
    margin-right: auto;
    clear: both;
}

#linkbarinternal {
    border-top:2px solid #aa0000;
    border-bottom:2px solid #aa0000;
    width: 500px;
    overflow: hidden;
    white-space: nowrap;
}

#linkbar ul, #linkbar li {
    display: inline;
    padding: 0px;
}
有帮助吗?

解决方案

  1. box-sizing:border-box
  2. You might need to remove whitespace around elements to get those tight fits right.
  3. #linkbarinternal need to have display: inline-block;

You will also have to work on margins and padding and/or height of elements.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top