Attempting to align a navigation block next to an SVG image

On my website, I envisioned a photoshopped image featuring a SVG picture of a book on the left and a "navigation block" on the right. The navigation block consists of links that redirect to other pages but it's not displaying properly. You can view the current issue in this screenshot: https://i.stack.imgur.com/OTZQJ.png

My code currently looks like this:

    <div id="custom-bg">
        <div id="alpha-layer">
            <div id="top-section">
                <div id="book">
                    <img src="img/book.svg" width="100">
                </div>
                <!-- nav -->
                <nav class="nav-bar">
                    <ul>
                        <li class="nav-button">
                            <a href="ada bio.html">Biographie</a>
                        </li>
                        <li class="nav-button">
                            <a href="site.html">Programme Ada</a>
                        </li>
                        <li class="nav-button">
                            <a href="babbage.html"> La machine de Babbage</a>
                        </li>
                        <li class="nav-button">
                            <a href="#">Exemple de progamme Ada</a>
                        </li>
                        <li class="nav-button">
                            <a href="bibliographie.html">Bibliographie</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>

Here is an excerpt from my CSS file:

html,

body {
    background-image: url("../img/bg32.svg");
    padding : 0px ;
    margin: 0px;
}

/* CSS styles omitted for brevity */

Any suggestions on what changes or additions need to be made in order to achieve the desired result?

Answer №1

To position the two divs next to each other (#book and .nav-bar), simply add display:inline-block to both:

.nav-bar, #book {
    display:inline-block;
}

Explanation: By default, a div element has a display of block, causing it to appear on a new line. Setting the display to inline-block removes this behavior while maintaining the width and height of the div (unlike using inline).

Check out the code snippet below for a visual demonstration:

html,

body {
    background-image: url("../img/bg32.svg");
    padding : 0px ;
    margin: 0px;
}

div#custom-bg {
    background-image: url("../img/bg32.svg");
    background-repeat: no-repeat;
    background-position : center;
    background-attachment: fixed;
    background-size: cover;
    padding-left: 2%;
    padding-right: 2%;
    padding-bottom: 0%;
    padding-top: 0%;
    max-height: 100%;
    max-width: 100%;
}

div#alpha-layer {
    background-color: rgba(255,255,255,0.25);
    padding : 25px;
}

div#top-section {
    display: inline-block;
}


nav.nav-bar ul li.nav-button {
    list-style-type: none;
}

.nav-bar, #book {
    display:inline-block;
}
<div id="custom-bg">
        <div id="alpha-layer">
            <div id="top-section">
                <div id="book">
                    <img src="img/book.svg" width="100">
                </div>
                <!-- nav -->
                <nav class="nav-bar">
                    <ul>
                        <li class="nav-button">
                            <a href="ada bio.html">Biography</a>
                        </li>
                        <li class="nav-button">
                            <a href="site.html">Ada Program</a>
                        </li>
                        <li class="nav-button">
                            <a href="babbage.html"> Babbage's Machine</a>
                        </li>
                        <li class="nav-button">
                            <a href="#">Ada Program Example</a>
                        </li>
                        <li class="nav-button">
                            <a href="bibliographie.html">References</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>

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

Is there a way to add a delay when opening all of the links on my web page

Has anyone experimented with implementing time delays on global links before? I am aiming to have all my links open with a delay in order to create a smoother transition between pages for an artistic touch. However, I seem to be encountering some issues ma ...

Centering H1 and dropdown button horizontally using Bootstrap

I positioned a dropdown button next to an H1 tag, but I noticed that they are not perfectly aligned and I want to move the dropdown button up slightly. My project is utilizing Bootstrap 5.1.3 https://i.sstatic.net/muIwB.png <div class="ps-4 pt-4 ...

PHP Warning: Attempt to access undefined variable

Whenever I try to insert a new record into my HTML, I keep encountering errors. I'm unsure if it's due to incorrect code on my end or if the issue lies with inserting the records. <?php $servername = "localhost"; $dbusername = "r ...

PHP function that includes an if statement in its returned value

Having a function that determines a user's role is functioning correctly within the HTML document. However, when multiple functions are involved in connecting to a database and displaying information, I encounter issues with granting access to certain ...

Is receiving an error message about a "stray start tag footer" in your HTML validator?

I am perplexed by the error message I am receiving: Stray start tag footer. All I have included here is the tags: <!doctype html> <head> <title>title</title> <meta charset="UTF-8"> <meta name="keywords" cont ...

issue with mark.js scrolling to selected sections

Our document searching functionality utilizes mark.js to highlight text and navigate to the results. You can see an example of this in action here. If you search for "Lorem ipsum" -> the highlighting works perfectly, but the navigation jumps to fragmen ...

Methods for updating the value of a `<select>` element in an AngularJS controller

Within my HTML code, I have a select element with options ranging from 1 to 10: <select id="selVal" ng-model="product.quantity" ng-options="o as o for o in quantityValues" ng-change="updateDelta(product.quantity, {{product.quantity}}, product.selec ...

Opt for filling background image instead of stretching it when the screen is resized

My background image resizes with the screen height but stretches when I change the width. The content that should appear below it completely covers the image. This is my current code: HTML: <div id="bg"> <img src="http://placehold.it/2560x1 ...

Hide the HTML DIV without altering the position of the current div

My goal is to conceal elements 1, 3 and 2 & 4 without changing their position. div{ width: 10%; float: left; } <div style="background-color: blue"><p>1</p></div> <div style="background-color: yellow"><p>2</ ...

Guide on embedding PHP code into a HTML div element using JQuery

I am having trouble loading PHP code into a div tag to display the results. The code I have listed below does not seem to work for me. If anyone can offer assistance in resolving this issue, I would greatly appreciate it. Here is the code snippet: <h ...

Implement a menu that can be scrolled through, but disable the ability to scroll on the body of the website

When viewed on a small screen, my website transforms its menu into a hamburger button. Clicking the button toggles a sidebar displaying a stacked version of the menu on top of the normal website (position: fixed; z-index: 5;). This sidebar also triggers a ...

How can I trigger the appearance of the navigation bar when reaching the second div while scrolling

Is there a way to make the navigation bar appear only when a user has scrolled down to the second div on the page? The first div is the header. I am wondering how this can be achieved using jQuery? <!DOCTYPE html> <html> <head> <me ...

Adjust the background hue and opacity when incorporating a "modal div"

Currently, I have a page where a hidden div appears at some point to display a form for inputting data. This could be considered a modal div. My goal is to darken the rest of the page and only allow interaction with this specific div. I want the backgroun ...

Guide on displaying a welcoming error notification within a Bootstrap modal form

How can I display an error message within a modal after clicking on the update button? In this example, I have included a required attribute on the input field. I would like to modify the error message based on recommendations from Form Validation Best Pr ...

Angular's Spanning Powers

How can I make a button call different methods when "Select" or "Change" is clicked? <button type="button" class="btn btn-default" *ngIf="!edit" class="btn btn-default"> <span *ngIf="isNullOrUndefined(class?.classForeignId)">Select</spa ...

Navigating with the keys is disabled until an item is chosen

Currently working on a Shopify website for a client and encountered an issue where the keys don't scroll down upon page load unless a specific element is clicked or tab is used. I am not sure what caused this unexpected behavior, it may have occurred ...

Resolving the Issue of Jerky Graphics During HTML5 Canvas Animation

When animating a layer in canvas, the visual quality becomes uneven if there are additional layers present. You can see an example of this by clicking "RUN" on this fiddle: http://jsfiddle.net/Q97Wn/ If I modify this line: opts.percentageIndicator.clearR ...

Position the Material UI Box element to the bottom of its parent container

Hello there, I've come across the following layout: <Box width="100%" height="100%" p={1}> <Box my={1} display="flex" justifyContent="center"> </ ...

Tips for displaying the number of selected values in a select box label (e.g. Choose an Option)

I am currently using the jQuery multiselect API in my application to allow users to select multiple values. However, I am facing an issue where I need to fetch all the selected values when a button next to the multiselect box is clicked. Unfortunately, I h ...

steps for including preset text in an input field within a form on WordPress

I am currently utilizing a WordPress plugin that automatically generates a form in the admin area based on user input. The form includes five fields that require URL validation. Users have the option to enter optional link text which will be displayed as t ...