Difficulty encountered in positioning a div element

I have been attempting to align the div with class bioDiv under the image, but despite various attempts, I find myself feeling more and more confused. Can someone please review the code for me and offer a clue? I want to retain the same appearance, just relocate the div to a more centralized position.

Here is the code:

body {
  width: 100%;
  height: auto;
  background-image: url("../img/marble-background.gif");
  background-size: 100% 100vh;
}

img {
  border: 10px solid #E3C640;
}

.menuDiv {
  background-color: white;
  height: 850px;
  width: 300px;
  margin-top: 70px;
  border: 15px solid #E3C640;
  padding-top: 50px;
  padding-right: 30px;
  padding-bottom: 50px;
  padding-left: 30px;
}

.bioDiv {
  background-color: white;
  height: 850px;
  width: 1200px;
  border: 15px solid #E3C640;
  position: relative;
}
<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title>Welcome to Cary McClures' Portfolio</title>
  <style type="text/css">
    @import url("bootstrap-5.1.3-dist/css/bootstrap.css");
  </style>
</head>

<head>

  <body>
    <img style="position: absolute; right: 600px; top: 68px
         " src="../img/images/me.jpg" width="400" height="600" alt="picture of cary" />
    <div class="menuDiv">
      <h2 style="color: goldenrod"><a href="index.html">Home</a></h2>
      <br>
      <h2 style="color: goldenrod"><a href="bio.html">Biography</a></h2>
      <br>
      <h2 style="color: goldenrod"><a href="ed.html">Education</a></h2>
      <br>
      <h2 style="color: goldenrod"><a href="gd.html">Graphic Design</a></h2>
      <br>
      <h2 style="color: goldenrod"><a href="free.html">Freelance</a></h2>
      <br>
      <h2 style="color: goldenrod"><a href="baking.html">Baking</a></h2>
      <br>
      <h2 style="color: goldenrod"><a href="photo.html">Photo Gallery</a></h2>
      <br>
      <h2 style="color: golden
      
      

Answer №1

If you're looking to improve the structure of your website, my recommendation would be to create separate containers for your navigation list and main content. In this case, you could use an aside element for the navigation and a main element for the image and bio. Here's an example:

.container {
  display: flex;
}
<div class="container">
  <aside>
    <h1>Put your nav here</h1>
  </aside>
  <main>
    <img src="" height="200" width="300" />
    <div>
      <h1>Put Bio here</h1>
    </div>
  </main>
</div>

By using semantic HTML5 tags like aside and main, you can provide clearer structure to your webpage. While you can substitute div elements for these tags, it's generally recommended to stick to semantic tags for better code organization.

Answer №2

If you're using Bootstrap, you don't need to worry about setting specific widths and styles manually. You can achieve the desired layout using standard Bootstrap CSS classes in your HTML. For example, you can make an image fluid inside a column like this:

<div class="col-sm-12 col-md-10 mx-auto">
   <img src="../img/images/me.jpg" class="img-fluid" alt="picture of cary"/>
</div>

This code will make the image full width (12 columns) on small screens and slightly smaller (10 columns) on larger screens, with the entire div centered horizontally. By adding the img-fluid class to the image, it will always occupy the full width of its container.

You can apply the same column setup for .bioDiv as well:

<div class="col-sm-12 col-md-10 mx-auto">
    <h2 style="color: goldenrod">Biography</h2>
    continued content here....
</div>

In essence, you just need to wrap the image in a div and set both the image and bioDiv to the same column specifications. Applying similar styling to menuDiv shouldn't cause any issues either.

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

Avoid Scrolling within an iFrame in HTML with the Use of #

I have a menu loading in an iframe with links using # like http://<location>/page.html#part1. When I click inside the iframe, the entire page outside of the iframe scrolls to the location of #. How can I stop this from happening? I only want the me ...

Tips on improving a function that verifies the existence of an image used as a CSS background to output a boolean value

I have encountered a challenge while working on a react file-upload component. The issue at hand is relatively simple - I aim to display an icon corresponding to the file extension for each uploaded file. These icons are loaded through css as background im ...

Tabindex malfunction in Bootstrap dropdown menu when nested within a form and pressing Enter key

Within my form, I have integrated a Bootstrap 3 dropdown menu situated between two text input fields. The dropdown's role="menu" attribute allows for navigation using the up/down arrow and Enter keys. However, after making a selection in the dropdown ...

Executing raml2html within an ANT automation script

I have a collection of RAML files stored in a specific folder, and I'm in the process of configuring an ANT script to "generate" them into HTML documentation utilizing the raml2html package which is highlighted on the raml.org website. While my expe ...

Seeking guidance on implementing toggle buttons for navigation bar items on mobile screens, enabling them to toggle for a dropdown menu. The tools at my disposal are HTML, CSS

I want to make the navigation menu responsive by adding a toggle button for the dropdown menu on mobile screens. Here is the code snippet: .nav-link { display: inline-block; position: relative; color: black; } html,body{ height: 100%; width ...

The button in my React.js app's Bootstrap carousel is unresponsive

I've been attempting to incorporate a Bootstrap carousel in a React component, but I'm running into issues with the Next and Previous buttons. While the automatic slide to the next item works and the images display correctly, the indicators butto ...

I'm having trouble figuring out how to remove an unexpected blank space that appears after the <li> element in a basic drop-down menu code. Can

Why is the browser (Mac Chrome + Firefox) adding extra space after my simple CSS drop-down menu where I have a hidden sub-menu? Check out the code below: <ul> <li>Option Zero</li> <li>Option One Is Longer</li> &l ...

Having trouble with submitting the code - need help resolving the issue

I'm facing an issue with my submit cancel code. The JavaScript code I implemented for preventing the submission function on my page isn't working as expected. While it does work to a certain extent, it's not fully functional. I am seeking a ...

Scripting events in JavaScript/jQuery are failing to trigger on elements located inside nested <div> containers

I am currently developing a simple RSS reader application where, upon clicking a 'story', the relevant information is displayed in a modal view. The 'stories' or RSS feed items are presented in a scrolling row. However, I have encounte ...

What is the process for creating a clickable file upload in Angular?

Currently, I am utilizing the instructions found in this guide to implement a file upload feature in my project. The code provided works perfectly: <input type="file" class="file-input (change)="onFileSelected($event)" #fileUplo ...

Troubleshooting: Issues with Adding a New Row in Datatables using JQuery

CSS : <div class="datatable-header"> <button type="button" name="add" id="add" class="float-right btn btn-info">Add</button> </div> <div class="table-responsive"> <table ...

Enhance the appearance of datatables pagination with a personalized touch

I am working on a page that utilizes server-side datatables and I want to implement a custom pagination style on it: HTML <ul class="pagination pagination-danger"> <li class="page-item"><a class="page-link" href="#" data-original-title ...

presentation banner that doesn't rely on flash technology

Looking to create a dynamic slideshow banner for my website inspired by the design on play.com. This banner will feature 5 different slides that transition automatically after a set time, while also allowing users to manually navigate using numbered button ...

Is it possible to automatically adjust the cursor position in a textarea when the language is switched?

I am working with a textarea that needs to support both English and Arabic languages. In English, text is typically left-aligned, so the cursor should start on the left-hand side. However, in Arabic, text is right-aligned, meaning the cursor should begin ...

Mastering nesting list-groups in Bootstrap 5.1 - A comprehensive guide

I'm currently utilizing the Bootstrap 5.1 list group component to craft a multi-level list group. This is my approach: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="96f4f9 ...

Enhanced Interactivity: jQuery UI Dialog Button Transforms Position upon Mouse Hover

I am utilizing the jQuery UI dialog feature and implementing buttons using jQuery in the following manner: $("#151").dialog({ autoOpen: false, autoResize: true, buttons: { "OK": function ...

Placing emphasis on an object that appears following a period of waiting

I'm currently working on enhancing the accessibility of a slider that will be featured on my website. The goal is to create an effect where, after clicking (or pressing enter) on the first slide, the focus shifts to the second slide element, allowing ...

How can you efficiently showcase multiple fetch functions on a single page by utilizing loops in PHP?

I am attempting to showcase the countries from each continent on a single page using buttons for each continent. When a user clicks on a button, I want the countries of the selected continent to be displayed. However, I am encountering an issue where only ...

How can I modify the font size of h1 and h2 elements in CSS?

I am currently working with a WordPress twenty eleven theme and I am trying to adjust the size of my headings. Specifically, when I enclose my headings in h1 and h2 tags like so: <h1>My h1 heading </h1> <h2> My h2 heading </h2> The ...

Struggling to effectively align the footer div in a responsive design

Check out this GitHub link to access the HTML file and CSS: https://github.com/xenophenes/pgopen-splash2016 I'm facing an issue with the footer text alignment. Despite my efforts, I can't seem to center it properly as it keeps appearing slightly ...