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

Need to adjust the layout of PHP form

Snippet of code: echo "<form method ='post' action='NextFile.cgi'>"; echo "<table>"; echo "<tr><td>Date: </td></td> <input type='date' name='Date' value =".$record['Date& ...

What is the best way to make a gradient fill and rounded border with CSS?

I am interested in creating a gradient and rounded border similar to the top bar on Instagram. Although I know how to create a rounded and solid border, this one utilizes a gradient. It appears that Instagram uses a canvas, but I am wondering if it can b ...

Designing a popup using Angular, CSS, and Javascript that is capable of escaping the limitations of its parent div

I'm currently working on an Angular project that involves components nested within other components. My goal is to create a popup component that maintains the same size and position, regardless of where it's triggered from. One suggestion I rece ...

The HTML anchor tag paired with the italic tag is a powerful combination for

Here is some example code: <a href="#"> <i class="some-bg" /> Some Text </a> Along with some Javascript: $("a").bind("touchstart", function (e) { e.preventDefault(); console.log("Tag: " + e.target); console.log("Tag Nam ...

creating a div that functions similarly to a radio button

Is it possible to create a div that mimics the behavior of a radio button? I'm looking for a solution that doesn't involve jquery, as many people have recommended. After doing some research, I found a few potential options. In the past, I'v ...

Creating a visually appealing label by customizing it according to the child div

Can the label be styled based on whether the input is checked or not using CSS, or do I have to use JavaScript? <label class="filterButton"> <input name="RunandDrive" type="checkbox" value="1"> </label> ...

"Fixing the position of a div on the Samsung Galaxy S8 navigation bar to

Here is the HTML code I am working with: <div class="app-bar"> <a href="#'>icon</a> <a href="#'>icon</a> <a href="#'>icon</a> <a href="#'>icon</a> </div>' ...

Adjust the transparency level of the image's mapped area

I need help with changing the opacity of a specific area on an image map when clicked. The image has three areas, but I only want to target and change the opacity of the test2 area regardless of which area is clicked. Since my knowledge of jQuery syntax is ...

JavaScript button for displaying and hiding all content in one click

I came across a tutorial on W3Schools that showed how to create collapsibles, and I thought it would be great to have buttons that could expand or collapse all at once. I've been trying to implement this feature using the code provided in the tutorial ...

How can you apply styling to one element when focusing on a different element at separate hierarchy levels?

I'm currently facing a challenge with styling a text field to expand when focused, and adding an "Add" button below it. The issue is that the elements are on different levels in the code structure, making it difficult to show or hide the button when f ...

Filling an HTML template with an $http response in VueJS

After learning about VueJs, I decided to embark on a small project - a nutrition app where food recommendations are made based on specific nutrients. Below is the JavaScript code snippet: recommendFood: function() { this.recs = {}; ...

When multiple input fields with an iterative design are using the same onChange() function, the specific event.target.values for each input

I'm in the process of developing a dynamic select button that adjusts based on the information entered into the iterative input fields I've set up. These input fields all utilize the same onChange() function. for (let i = 0; i < selectCount; i ...

Place a fresh banner on top of the Ionicon icon

I recently started using Ionicons from and I am not too familiar with css. My question is, can a banner that says 'new' be overlaid on the top right corner of the Icon? Is there a simple or standard method to achieve this? (whether it's an ...

Perform a toggle action on the first row when clicking within the current row using Jquery

I've been grappling with the idea of creating a function that can display and hide a comment field when a button is clicked. The challenge here is that there are multiple line items with their own comment boxes. I want to find a way to achieve this wi ...

What is the best way to apply a hover rule to a CSS class in order to change the color of a specific row when hovering in

I have managed to successfully apply a classname and add color to a specific row in my react-table. However, I am facing difficulty in adding a hover rule to this className to change the color when I hover over the row. Can someone guide me on how to apply ...

Refreshing GIF images in React using forceReload

In order to restart the gif animation every 12 seconds or whenever the activeIndex changes, I need to reload a GIF image with CHECKMARK_ANIMATION_ICON as the source. Below is the code: const reloadImgSource = (imgSource) => { setTimeout(() =& ...

Is it acceptable to replicate another individual's WordPress theme and website design in order to create my own WordPress website that looks identical to theirs?

It may sound shady, but a friend of mine boasts about the security of his WordPress website, claiming it's impossible to copy someone else's layout or theme. However, my limited experience in web development tells me otherwise. I believe it is po ...

Please enter a number using the "+" sign and a decimal point

In my input field, I have specified: <input type="number" step="0.01"> I expect all of these input values to produce the following outputs: 2.00 => 2.00 2,00 => 2.00 +2,00 => 2.00 However, when entering the value "+2.00", it fail ...

Choose class based on the retrieved information

Good morning, I am working on dynamically setting the class of a td element based on data fetched from a database to reflect any changes or updates. One of the fields returned has four possible options, and I need to modify the CSS class of that field acc ...

When trying to use ngModel with Angular, an error occurs where the property 'selected' cannot be created on a string

I'm currently attempting to utilize [(ngModel)] in the following manner: <div class="items"> <tbody> <tr *ngFor="let info of this.information"> <td> <input type="checkbox" [(ngModel)]="this.info.n ...