What is the best way to position elements with CSS?

I need help aligning the arrows and images on the same line. Can anyone guide me on how to do this? (I'm using html5boilerplate).

Desired Layout:

Current Layout:

Existing 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;
}

Answer №1

  • box-sizing:border-box
  • To achieve a perfect fit, consider removing any unnecessary whitespace around elements.
  • The #linkbarinternal element must have display: inline-block; for proper alignment.

In addition, adjusting margins, padding, and height of elements is necessary for the desired layout.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unexpected background image slideshow appearance

I am encountering an issue with my slideshow where the last image briefly appears before the first image loads in a continuous loop. The offset of the initial image causes it to start at the middle of the window, and in Google Chrome and Safari, subsequent ...

Extract the value of an HTML tag and store it in a PHP variable

I have successfully implemented JavaScript code to dynamically update the value of an input tag in my popup. However, when I try to echo out this updated value using a PHP variable within the same popup, it doesn't seem to work as expected. Despite un ...

Is it possible to store multiple keys in HTML local storage?

Is there a way to store multiple keys to local storage without overwriting the previous ones when multiple people take a survey and refresh? Could they be grouped by userID or sorted in any way? $('form').submit(function() { $('input, ...

Troubleshooting Flexbox in Internet Explorer 11: Issue with 100% width not functioning properly within nested flex containers with a 'column'

Is there a way to ensure that an image within nested flex containers has a width of 100% in IE11, even when the container has flex-direction: column? I've tried setting the width to 100% with a max-width of calc(100% - 0.1px), but unfortunately it doe ...

bootstrap navigation bar collapsible menu

Struggling with making the hamburger menu appear on my friend's site. Spent hours trying to troubleshoot, but still can't figure out why it's only showing up as a red box and appearing on larger screens instead of just smaller devices. Frust ...

Is it possible to enhance a form box with a border?

Having trouble adding a border to my bootstrap form box. I've tried applying border style properties but it doesn't seem to be working. Any suggestions? This is the class for the form box: <div class="form-box"> <div ...

Make HTML design responsive to any screen size

After completing the design of a mobile app interface with dimensions 750w by 1334H, I encountered an issue where it appears too large on the app testing screen. I am seeking a way to automatically adjust the design to fit all screens without compromising ...

When I click the submit button in HTML PHP, the text in the text field disappears. How can I make sure the text stays

I am facing an issue with the functionality of my form's submit button. When I click the button, the text in the text field disappears, but I need it to remain for another button that requires it. These two buttons are part of different functions, and ...

Is there a way to transfer a significant volume of data from one webpage to another without relying on the POST

Currently, I am utilizing a web server framework that exclusively operates with GET requests. Presently, my task involves transferring a substantial volume of data (specifically the text content in a textarea) inputted by users onto another page where it i ...

What is the best way to position a popup div in CSS?

Currently, I am in the process of developing a website that displays DVD details when hovering over an image, similar to what is shown in picture 1. However, I've encountered an issue where the content gets cut off for DVDs located on the right side o ...

Exploring ways to customize the selected text color within a jQuery mobile division using CSS

Is there a way to change the color of selected text to #3C3 for the div one only and not for div two? <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link ...

What are the steps to create a unique popup div effect with jQuery?

Upon clicking the icon on this page, a mysterious div appears with information. I'm completely baffled by how they achieved this cool effect using css/jQuery tools. Can anyone shed some light on the mechanism behind this? ...

Creating dynamic pages using user input in Node and Express

Currently, I am facing a challenge in rendering text using node/express. Within my project setup, there is an HTML file containing a form. The file named search.ejs looks like this: $(document).ready(function(){ var userInput; $("#submit-button-i ...

Having trouble with your HTML5 canvas?

Below is the JS code snippet: function DisplayText(output, x, y){ var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext("2d"); ctx.fillText ("A" , x, y); ctx.font = 'bold 20px sans-serif'; ...

quickest method for accessing the selected radio button using jQuery

I'm trying to use jQuery to retrieve the selected radio button and display the text associated with that radio button. <div id="Poll"> <div id="PollQuestion">Your favorite color?</div> <ul> <li class="liAnsw ...

In the readmore.js script, position the "readmore" link within a div instead of outside of it

I have added annotations that vary in length, so I am looking to integrate the readmore.js plugin. To ensure uniform sizing for all annotations (even empty ones), I need to set a minimum height for the div container. <annotation> <div style="wi ...

Addressing a jquery.ajax relative path problem

I am a newcomer to this topic and I have been researching extensively online for more information. I would like some further insight into the following issue: I am attempting to retrieve a JSON file located one level down from the directory where `index.h ...

Angular JS: Grabbing Text from a Specific div and Copying it to Clipboard

I recently developed a Random Password Generator using Angular JS. Here is how the output appears in the application: <div data-ng-model="password" id="password"> <input class="form-control" data-ng-model="password" id="password" placeholder=" ...

Slow and choppy animations with jQuery

I've been struggling with a slow and choppy jQuery animation despite trying various techniques to improve its speed. I've attempted stopping existing animations before starting new ones, ensuring animations are only performed when necessary, and ...

Loading Kendo JS on the client side proves to be rather time-consuming

Working on my project, I have encountered a problem with the kendo ui scheduler where the downloading of the kendo js and css files on the client side is causing slowness on our website. To address this issue, we are attempting to download the kendo js and ...