Achieving Perfect Alignment of Images Using HTML and CSS

I am currently working on designing a HTML/CSS layout for a Kiosk-style website.

However, I am encountering some challenges in getting the alignment of images and text to appear exactly as desired.

The goal is to have the logo and header remain fixed in the same position on every page, while potentially expanding the number of buttons displayed on the screen.

For reference, you can view an example illustration here: Example Image, where:

  • The black box represents the logo
  • The blue boxes represent individual buttons

Here is the current HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link rel="stylesheet" type="text/css" href="style.css">
<html>
<body background="background.png"> 

<div id="logo">
    <img src="logo.png">
</div>

<br>

<div id="icons1">
    <img src="button-wmcweb.png"></a>
</div>

<div id="icons1">
    <img src="button-appointments.png"></a>
</div>

<div id="icons1">
    <img src="button-prescriptions.png"></a>
</div>

<br>

<div id="icons2">
    <img src="button-somccg.png"></a>
</div>

<div id="icons2">
    <img src="button-patient.png"></a>
</div>

<div id="icons2">
    <img src="button-nhschoices.png"></a>
</div>

</body>
</html> 

CSS Styles:

body {
text-align:center;
}

#mainContainer {
margin:0 auto;
} 

#icons1 {
  display: inline-block;
}

#icons2 {
  display: inline-block;
}

I'm wondering if using inline blocks is the most effective approach for achieving my design goals?

Any assistance on this matter would be greatly appreciated.

Answer №1

Here is a JSFiddle I created to help you get started.

If you'd like to view the fiddle in full screen mode, simply click here.

You can also find the complete code below for easy reference.

index.html:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body background="background.png">
        <div id="logo">
            <div id="logoimg">
                <img src="http://cs614926.vk.me/v614926650/93b6/n9S5OGKt8L0.jpg" />
            </div>
            <div id="logotext">lorem ipsum</div>
        </div>
        <div class="row"> <a href="http://stackoverflow.com/">
            <img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
            </a>  <a href="http://stackoverflow.com/">
            <img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
            </a>  <a href="http://stackoverflow.com/">
            <img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
            </a>

        </div>
        <div class="row"> <a href="http://stackoverflow.com/">
            <img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
            </a>  <a href="http://stackoverflow.com/">
            <img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
            </a>  <a href="http://stackoverflow.com/">
            <img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
            </a>

        </div>
    </body>
</html>

style.css:

body {
    text-align: center;
}
#logoimg, #logotext, .row > img {
    display: inline;
}
#logo, .row {
    margin: 30px 10px;
    min-width: 1000px;
}
#logotext {
    min-width: 320px;
    vertical-align: top;
    font-size: 36px;
    padding: 0 20px;
}
img {
    width: 320px;
    resize: noresize;
}
a:link {
    text-decoration:none;
}

If you're interested in learning more about HTML/CSS, be sure to check out these helpful tutorials from w3school: HTML and CSS.

Answer №2

We found a few errors in your HTML code. You forgot to include an opening <a> tag, used the same id multiple times, and didn't place the <link> for the CSS inside the <head></head> tags.

<head>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>

Do you want to achieve this outcome?

http://jsfiddle.net/Q8gVL/

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

Revamped Web Presentation: The Dynamic Blend

I'm struggling to arrange a section in the same way as shown in this image. https://i.stack.imgur.com/QVDHn.png I have been using bootstrap 4 and have experimented with rows and columns, but haven't been able to achieve the desired layout. Curr ...

The min-width of 100vh is functioning properly on mobile devices, however, it is not working as expected on PCs when set to 100

When using 100vh, it only works on mobile or if you narrow the width of your web browser on a PC. If the window/width is set at 100%, the image may appear too tall and cause the div class "mars" to overflow the viewport. Unfortunately, screenshots cannot ...

Issue with creating a new jstree node

I recently put together a basic jstree. When I click on a link, it triggers the createNode() function. This function utilizes the create feature from the API to generate a new node. It appears to be a common issue with jQuery that I am encountering. Any ...

What is the best way to make a dropdown button on a top navigation bar show as active using Semantic-ui?

I searched through the Semantic-ui documentation, but I couldn't find clear instructions on how to designate a dropdown item as 'active' (highlighted without being opened) in my top navbar menu, similar to regular items. The 'active&ap ...

Ensuring the text remains positioned above another element constantly

Looking to have the text float above a regular box and resize the font size accordingly? Here's what I've tried: https://jsfiddle.net/a87uo3t2/ @import url('https://fonts.googleapis.com/css?family=Share+Tech+Mono'); body { margin: ...

Leveraging strings as URLs to embed PDFs in Wordpress using PDF Embedder

I'm encountering an issue related to a Wordpress plugin called PDF Embedder, as well as concatenating/using a string with document.write. My goal is to make this code work: <script src="http://nooze.org/wp-content/uploads/scripts/dateGetter.js"> ...

What is the best way to adjust the vertical margin in a vis.js timeline?

The vis.js timeline sets a margin of 5px in each row using inline styles that are controlled programmatically by the library. The height, top position, and transform of each item within the row are specified by the library as well. Attempting to manually ...

Styling the background of a container in CSS using Bootstrap

Currently, I am utilizing bootstrap and trying to find an elegant solution for adding a background to my container. Specifically, I am working with the bootstrap class container, as opposed to container-fluid. The official Bootstrap documentation advises ...

Ways to eliminate gaps between div elements with CSS

I am currently working on a webpage that consists of one main div housing two inner divs (left_menu and content), along with an additional footer div outside the main container. When viewing the page, there seems to be a noticeable gap between the footer ...

Issues arise with animated content when viewed on browsers other than Chrome

After coding some jQuery, I noticed that the animation is working properly in Chrome but not in IE (version 11.0) or Firefox (32.0.3). Additionally, I found that if I omit 'opacity: 1;' from my animation class, the element will revert back to it ...

Drop and drag to complete the missing pieces

Here is a drag and drop fill in the blanks code I created. The challenge I'm facing is that I want users to be able to correct their mistakes by moving words to the right place after receiving points. <!DOCTYPE HTML> <html> <head&g ...

Implementing a switch to trigger a JavaScript function that relies on a JSON object retrieved from a GET request

Having some trouble using a toggle to convert my incoming Kelvin temperature to Celsius and then to Fahrenheit. It loads properly as default Celsius when the page first loads, but once I try toggling the function outside of locationLook, it doesn't se ...

Django failing to detect empty URL configuration

Hey there! I'm new to this, and I was trying out a tutorial on py/django. The web server is up and running, but it's only showing the default page: Even though my urls.py has the default page set. urls.py from django.contrib import admin from d ...

The <span> tag creating a surprise gap following a word

Using Angular4, I've come across an odd issue where one of my span elements is adding an extra space to the end of words like this: https://i.stack.imgur.com/H4TD7.png The only CSS properties that are set include font-family, -webkit-font-smoothing, ...

The HTML source code in the browser varies from the output obtained through Python requests

I've noticed a discrepancy between the HTML source code displayed in my browser and the code I receive when using Python's requests.get function. You can see the image depicting this issue at the following link: Any thoughts on why this might be ...

Solving issues with flexboxes in Safari 5.1.7 on Windows

I am currently utilizing flex boxes for managing the layouts of my website. However, it seems that the Safari version for Windows (5.1.7) is outdated and causing all flex boxes to be dysfunctional. On MacOS systems, the same version 12.x works correctly. ...

Utilize Express Handlebars to render an input-generated list for display

My goal is to showcase a collection of wishlist items on a basic webpage through user interaction. Here's how I envision it: 1. do something 2. do another thing 3. blahblah This snippet shows my index.js code: var wishlist = []; router.post('/& ...

Error 410: The Webpage has Disappeared

Unfortunately, my website fell victim to a hacking attack that resulted in the addition of numerous unwanted pages. These pages were quickly indexed by Google, causing a significant drop in traffic. The names of these pages all follow a similar pattern, s ...

CSS: Navigation links at the bottom of the page

I am looking to design a menu where all the menu items are aligned at the bottom, even if they span across multiple lines. ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: ...

When hovering over the main menu, the submenu appears hidden behind it

I am struggling with setting up a dropdown submenu on my website that uses a responsive Joomla template. The submenu always appears behind the main menu and slider, despite trying z-index and relative positioning. Can anyone help me figure out what I' ...