What is the best way to align my image correctly?

I've created a simple navigation that triggers an animation and opens a drop-down menu when you click on a plus sign.

However, I am struggling to position the element using CSS despite trying various combinations. Can anyone identify what I might be doing incorrectly?

Here is the CSS code:

body {
    background-image: url(bg.png);
    background-size: cover;
    background-repeat: no-repeat;
}

html,body {
    height: 100%;
}

.aspectwrapper {
    display: inline-block;
/* adjust to fit */
    width: 100%;
/* set desired width */
    position: relative;
/* allows .content to use position: absolute */
}

.aspectwrapper::after {
    padding-top: 56.25%;
/* percentage of parent block's _width_ */
    display: block;
    content: '';
}

.content {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
/* aligned with parent's edges */
    outline: thin dashed green;
/* visual aid for box outline */
}

#links {
    position: relative;
    left: 300px;
}

The 'links' div contains the entire navigation section. It seems like I should focus on positioning this div correctly.

Here is the HTML code:

<div class="aspectwrapper">
    <div class="content">
        <div class="links">
            <ul>
                <li><a href="#design"><img height="20" src="1.png"></a></li>

                <li><a href="#object"><img height="20" src="2.png"></a></li>

                <li><a href="#architecture"><img height="20" src="3.png"></a></li>

                <li><a href="#contact"><img height="20" src="4.png"></a></li>

                <li><a href="#shop"><img height="20" src="5.png"></a></li>
            </ul>
        </div>
    </div>
</div>

Any assistance would be greatly appreciated.

Answer №1

Your CSS code mistakenly identified the links class as an ID. To correct this, simply update:

#links {
    position: relative;
    left: 300px;
}

to

.links {
    position: relative;
    left: 300px;
}

For a visual demonstration, check out this fiddle: http://jsfiddle.net/5Ejgx/

Hopefully, this resolves the issue for you!

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

Creating seamless video playback in Dreamweaver by looping an FLV file

I need help with loading my FLV video via Dreamweaver and making it loop continuously after it finishes playing. Can someone guide me on how to achieve this? Below is the code I have: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width= ...

Media queries for the header background image display

I am currently working on a small web project and I want to change the background image in the header section while also making it responsive. I attempted to use a class called "header_accueil" in my header to distinguish different sections of the site, bu ...

Updating values on an HTML page upon clicking a button can be achieved using AngularJS

Link to view my project demo: http://jsfiddle.net/Lvc0u55v/6741/ Utilizing AngularJS in my project. In the code snippet below, if a movie is not found, previous values should not persist: <form style="margin-bottom: 40px;"> <ul> ...

Instructions for submitting three different forms from three separate pages simultaneously

I am facing a challenge where I have 3 forms spread across 3 different pages, with the submit button located on the 3rd page. Is there a way to submit all 3 forms simultaneously by clicking on the submit button? Are there any solutions available in javascr ...

Adjusting font size to perfectly fit within its confines

When using v-for to map out objects from an array into cards, it's important to keep the height consistent throughout the section. Manually adjusting text size with @media queries can be tedious and inelegant, requiring multiple rules for different sc ...

Innovative JavaScript function

Seeking a solution for my JavaScript function that should only be executed when the browser screen width exceeds 1024px. if ($(window).width() > 1024) { An issue arises when a user initially loads the webpage on an 800px browser screen and then resize ...

Performing Jquery functions on several elements at once

Looking at the code snippet below, there are two buttons and an input in each container. The input calculates and adds up the number of clicks on the 2 buttons within the same container. However, it currently only works for the first container. How can thi ...

Ways to verify if all javascript and css files have been successfully loaded

I have been exploring different ways to notify users if certain resources do not load correctly. So far, I have come across the following methods: For CSS, I stumbled upon an example in the source code of Trello: <div id="nocss"> Your browser ...

Error Encountered: Anticipated 'styles' to consist of a series of string elements

I have attempted various solutions for this particular error message without any success. When launching my angular project using the angular cli via ng serve, everything runs smoothly with no errors. However, upon compiling it with webpack, I encounter th ...

Height Adjustment on Facebook Tab Scroll Bars

After creating a basic HTML page and setting it up on my Facebook fan page tab, I noticed that a scroll bar appears even though I have already set it to auto-resize. The height of the HTML page is quite large, and I want to find a way to hide the scroll ...

Comparing Ajax HTML with XML/JSON responses: which is better for speed or other considerations

I have a website that heavily relies on ajax, and I insert around 3k html formatted pages into the DOM through ajax requests. My current approach involves inserting the entire html responses using jQuery. However, another option is to output in xml or jso ...

Move the width from left to right with animation

Currently, I am exploring ways to use jQuery to create an animation effect on a div where the width shrinks from left to right. My first step is to have the element animate as follows: Slide in from left to right Then continue moving to the right off th ...

Identify and mark labels when hovering over them

Hello everyone! I'm completely new to this, so please be gentle :). Apologies in advance if my terminology is off. I have zero experience with HTML, but I landed here from working with FileMaker. Currently, I am developing a FileMaker database for my ...

Using Vuejs v-for on inline elements can remove unnecessary whitespace

While iterating through an array (or object) with v-for on an inline element in VueJS, there is no whitespace rendered around the element. Consider the following example: <div id="app"> Vue Rendering<br> <a v-for="fruit in fruits" ...

Having trouble with the backspace key on mobile devices?

function createAdditionalDiv() { let innerBox = document.createElement('div') innerBox.contentEditable = "true" innerBox.id = totalBoxes++; innerBox.className = "mainBox" ...

Trying to reduce the cursor box area within an A link containing a div box

My communication skills are lacking, so I have included an image to better illustrate my issue. Here is the problem .body { text-align: center; display: flex; flex-direction: column; align-items: center; } .flex-container { display: flex; ...

I'm having trouble with my bootstrap row because it's not displaying all three columns in one line as depicted in the screenshot. What could

When viewing on a phone screen, it should resemble the screenshot linked below: Image In the screenshot, the specific row and column that I am referring to is highlighted in black. Interestingly, when I deactivate the "width" of the row, it functions corr ...

Is there a way to change my cursor to a pointer finger when hovering over my box?

<script type="text/javascript"> function draw() { var canvas = document.getElementById('Background'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.lineWidth = 0.4 ctx.strokeRect(15, 135, 240, 40) Is there a w ...

What steps should I take to adjust the CSS code to properly integrate with my HTML file?

There seems to be an issue with the code provided. The CSS for the menu bar is not functioning properly with the HTML. <!DOCTYPE html> <html> <body class="news"> <head> <style type="text/css">body { margin: 0; paddi ...

Converting a JavaScript object into HTML output

I have received the following JSON data: [    {       "fields": {          "url": "http://www.domain_name.co.uk/MP3/SF560783-01-01-01.mp3\n",          "track_name": "Lion City ",          "release_id": 560783,    ...