Is there a way for me to position my menu on the right side of my website?

I am currently working on a gallery website and facing an issue with the menu placement. I want to position the menu items on the right side of the images, but they keep appearing at the bottom instead. Despite adjusting the width in classes like gallerymenu and menutyle, the problem persists. Can anyone suggest a solution to achieve the desired layout?

<body class="galleryStyle">
    <div class="galleryGrid"> 
      <div class="galleryContainer">
        <div>
          <a href="google.com.html">
            <img src="https://upload.wikimedia.org/wikipedia/en/2/23/Philipgiaccone1.JPG" alt="google">
          </a>
        </div>
      </div>
      <div class="galleryContainer">
        <div>
          <a href="google.com.html">
            <img src="https://upload.wikimedia.org/wikipedia/commons/1/19/Delfini-Milian_cropped.png" alt="google">
          </a>
        </div>
      </div>
      </div>
<div class="galleryMenu">
    <div class="menuStyle">
      <a href="google.com">
        <p>google</p></a>
    </div>
    <div class="menuStyle">
      <a href="google.com">
        <p>google</p></a>
    </div>

.galleryStyle {
  color: grey;
  width: 100%;
  background: white;
}

.galleryContainer {
  height: auto;
  width: 15%;
  margin: 10px;
  padding: 15px;
}

.galleryGrid {
  display: grid;
  grid-template-columns: repeat(2, 8fr);
  padding: 5px;
  margin: 10px;
  height: 100%;
  width: 60%;
}

.galleryMenu  {
  height: 30%;
}

.menuContainer>div {
  font-size: 2vw;
  text-align: center;
  border-radius: 5px;
  box-shadow: 8px 13px black;
  margin: 50px;
  height: 50%;
  width: 40%;
}

.menuStyle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: red;
  margin: 10px;
}

https://jsfiddle.net/ud3rfm2o/1/

Answer №1

If you're looking to update your code, consider using float:left for the images and float:right for the menu. Additionally, apply a width of less than 40% to the menu and a margin-top of 40px for proper alignment.

However, many developers find flexbox to be a more straightforward solution.

.galleryStyle {
  color: grey;
  width: 100%;
  background: white;
}

.galleryContainer {
  height: auto;
  width: 15%;
  margin: 10px;
  padding: 15px;
}

.galleryGrid {
  display: grid;
  grid-template-columns: repeat(2, 8fr);
  padding: 5px;
  margin: 10px;
  height: 100%;
  width: 60%;
  float:left;
}

.galleryMenu  {
  height: 30%;
}

.menuContainer>div {
  font-size: 2vw;
  text-align: center;
  border-radius: 5px;
  box-shadow: 8px 13px black;
  margin: 50px;
  height: 50%;
  width: 40%;
}

.menuStyle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: red;
  margin: 10px;
  width:25%;
  float:right;
  margin-top:40px;
}
<body class="galleryStyle">
    <div class="galleryGrid"> 
      <div class="galleryContainer">
        <div>
          <a href="google.com.html">
            <img src="https://upload.wikimedia.org/wikipedia/en/2/23/Philipgiaccone1.JPG" alt="google">
          </a>
        </div>
      </div>
      <div class="galleryContainer">
        <div>
          <a href="google.com.html">
            <img src="https://upload.wikimedia.org/wikipedia/commons/1/19/Delfini-Milian_cropped.png" alt="google">
          </a>
        </div>
      </div>
      </div>
<div class="galleryMenu">
    <div class="menuStyle">
      <a href="google.com">
        <p>google</p></a>
    </div>
    <div class="menuStyle">
      <a href="google.com">
        <p>google</p></a>
    </div>

Answer №2

Utilize flexbox for optimal layout:

    <body class="galleryStyle">
    <div class= gallery-wrap>


        <div class="galleryGrid"> 
          <div class="galleryContainer">
            <div>
              <a href="google.com.html">
                <img src="https://upload.wikimedia.org/wikipedia/en/2/23/Philipgiaccone1.JPG" alt="google">
              </a>
            </div>
          </div>
          <div class="galleryContainer">
            <div>
              <a href="google.com.html">
                <img src="https://upload.wikimedia.org/wikipedia/commons/1/19/Delfini-Milian_cropped.png" alt="google">
              </a>
            </div>
          </div>
          </div>
    <div class="galleryMenu">
        <div class="menuStyle">
          <a href="google.com">
            <p>google</p></a>
        </div>
        <div class="menuStyle">
          <a href="google.com">
            <p>google</p></a>
        </div>
        </div>
.gallery-wrap{
  display:flex;
  flex-direction:row;
   justify-content:space-between;

}
.galleryStyle {
  color: grey;
  width: 100%;
  background: white;
}

.galleryContainer {
  height: auto;
  width: 15%;
  margin: 10px;
  padding: 15px;
}

.galleryGrid {
  display: grid;
  grid-template-columns: repeat(2, 8fr);
  padding: 5px;
  margin: 10px;
  height: 100%;
  width: 40%;
}

.galleryMenu  {
  height: 30%;
  flex-grow:1
}

.menuContainer>div {
  font-size: 2vw;
  text-align: center;
  border-radius: 5px;
  box-shadow: 8px 13px black;
  margin: 50px;
  height: 50%;
  width: 20%;
}

.menuStyle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: red;
  margin: 10px;
}

For more in-depth information on using flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Answer №3

experiment with float: right; for the galleryMenu:

.galleryMenu  {
  height: 30%;
  float: right;
}

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

What is the best way to adjust the spacing between posts on a website

https://i.stack.imgur.com/VderY.jpg Looking at the image, there are 3 posts lined up in a row. I'm trying to adjust the spacing between each item to be about 20%. Specifically, I want the distance highlighted by the red dashes, instead of the current ...

The gap separating the three columns in the DIVs structure

Here is an example that I need The images are being loaded from a MySQL while loop, and I want the spacing between them to be such that the left column and right column touch each side with the middle image centered. Just like in the picture :D This is m ...

When you hover over one box, watch as another magically vanishes

How can I make one div disappear by hovering over another? When I use the code .icon:hover + .info { display:none), it just displays that div underneath instead of making it disappear. I'm not sure if the placement of the divs in the HTML is affectin ...

Minimize the screen dimensions and adjust the margins accordingly

Having a problem with responsive margins? Take a look at this site as an example: When I shrink the screen size, the margins decrease and smoothly transition from 4 to 2 columns. In my case, it does something similar but the issue is that the margin does ...

Is it possible to maintain tab focus instead of visual focus when navigating past the skip navigation menu for improved accessibility?

My website features an accessibility skip navigation menu that utilizes named anchors to navigate to different content areas. These content areas, including the top menu, left menu, main body content, and footer menus, contain links within them. When I u ...

Styling images side by side with CSS in Internet Explorer

I've encountered a CSS dilemma. I have a collection of images that I want to present side by side using an unordered list within a fixed width container. The goal is to have 3 images per row before moving on to the next set of 3 images. Each list ite ...

How to set the default theme color for the mat-sidenav background in Angular 6 and 7?

Is there a way to make the background of a mat-sidenav match the theme color of my mat-toolbar? In the file src\styles.scss, I have the following: @import '~@angular/material/prebuilt-themes/indigo-pink.css'; The template / HTML file incl ...

Creating dynamically adjustable columns in Bootstrap

I've created a simple code for experimentation purposes: <!doctype html> <html lang='en'> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" ty ...

Retrieving Basic HTML Source Code in UITextView Without CSS Styling Using Objective-C

I am looking to make changes to HTML text within a UITextView. The original text was created using an HTML editor in the web version of the app and needs to be edited with a default font on iOS. Here is the simple HTML code for the text that needs editing ...

Excessive content spilling over the div container

Hello everyone I've been trying to set up a div that includes an image, a title, and some text. I want the image to be aligned on the left side, with the title and text following on the right. However, I'm having an issue where the text is overf ...

Transferring information from website form to a C# program

Someone suggested using the HTTPListener class, but it appears to only return another web page in response. I need guidance on how to post data from a form on my website and process it in my C# application. If anyone has tutorials or simple examples, the ...

Is there a way to dynamically update text using javascript on a daily basis?

I am currently developing a script to showcase different content and images every day. While I have successfully implemented the image loop to display a new picture daily, I need assistance in achieving the same functionality for the title. My aim is to c ...

Do HTML buttons without values get sent in a form submission?

When you have a button with the following code: <button class="button yellow" type="submit" name="button">Log in</button> and you submit it, what exactly gets sent to the server for this specific button that has a name attribute but no value ...

Can variables be declared for file paths within the HTML code in a TypeScript file?

We utilize the Vaadin designer to create the frontend of our project. Within the .ts files, we have images where we aim to establish variables for the file paths. Currently, the setup looks like this: <img src="../../themes/light/img/example.jpg&q ...

What is the best way to eliminate a class from a jQuery UI Dialog?

Can a specific class be removed from the jQuery UI dialog? http://api.jqueryui.com/dialog/#option-dialogClass I'm curious if there is a way to remove a particular class from the dialog. Thank you. ...

Footer not being pushed down by content in mobile view on page

Hello everyone, Can you assist me with a query, please? My form works perfectly fine in desktop view, but it gets cut off on mobile view and I'm unsure of the reason why. Here is my code: .upload-pic { position: absolute; max-width: au ...

How can I align an input to the right using Bootstrap?

I found an example of a navbar that I liked and decided to copy it. Here is the code snippet: <div class="container"> <h3>Nawigacja zamknieta w kontenerze</h3> <nav class="navbar navbar-toggleable-md navbar-light bg-faded"> < ...

Customize YouTube iframe styles in Angular 4+ with TypeScript

Has anyone been successful in overriding the style of an embedded YouTube iframe using Angular 4+ with TypeScript? I've attempted to override a CSS class of the embed iframe, but have not had any luck. Here is the URL to YouTube's stylesheet: ...

What methods can we use to transform Bootstrap rows and columns to resemble a table design?

Attempt number one did not work due to padding issues in the columns. Attempt number two also failed, leading me to believe I may be making a mistake somewhere. This is what I am aiming for: Can anyone provide some assistance? I would prefer avoiding mo ...

Tips to successfully utilize addEventListener on a submit action

Having issues getting this to work on submit, it functions properly when using document.getElementById("gets").addEventListener("click", b_button); but does not work when I try document.getElementById("gets").addEventListener ...