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

Apply a class to each element that contains the specified name attribute

I have successfully implemented a prices tab on the top of my page, with tabs for different packages at the bottom. When a user selects a certain package, only specific items from the list are visible while the others are hidden. I managed to streamline ...

Switching the background image upon hover while incorporating a subtle fade transition in HTML and CSS

Is there a way to set two background images on a div and have them change when hovering with a fade effect? Similar to the example shown. .kid { max-width:50%; position:relative; } .kid img { display:block; opacity:1; height: auto; transition:.6s ease; ...

How can I exclude specific lines from an XML file using filters?

Let's say I have the following data: <div class="info"><p><b>Orange</b>, <b>One</b>, ... <div class="info"><p><b>Blue</b>, <b>Two</b>, ... <div class="info"><p><b& ...

More content will not be displayed beneath folded DIVs arranged to stack on mobile devices

On my website, I have two separate sections dedicated to use cases and benefits. Here is the code: .onboardmessaging { min-width: 100%; } .onboardmessagingwrap { min-width: 100%; } .usecase { padding-left: 8vw; max-widt ...

Shapes and their corresponding encoded representations compiled in a comprehensive catalog

Can anyone provide me with a comprehensive list of HTML escaped codes for displaying various shapes on web pages? I need codes that are universally compatible with all browsers. For instance, I would like to display a square using an escaped code in one ...

CSS | Creating gaps between elements within a form

My form is currently inside a flexbox card with two sides - left and right. The left side displays a picture, while the right side contains the actual input fields. I'm looking to add more space between the different inputs as they feel too cramped at ...

Utilizing CSS to showcase sub-categories alongside primary categories following PHP rendering

1: In my database I have a hierarchical table of categories: 2: I created a PHP script to convert this table into HTML: 3: The resulting HTML code is as follows: <script> function toggleSubCategories(button) { ...

Utilize a SCSS class defined in one file within a different SCSS file

In my React project, I have a day/night theme button that changes the main body color in the App.scss. It's a simple setup using body.light and body.dark. However, I need to also change the text color in the navigation bar, which is located in a diffe ...

The challenges with implementing makeStyles in React Material UI

const useStyles = makeStyles((theme) => ({ toolbarMargin: { ...theme.mixins.toolbar, marginBottom: "3em", }, logo: { height: "7em", }, tabContainer: { marginLeft: "auto", }, tab: { ...theme ...

If either the form is invalid or has been submitted, disable the button

Is there a way to either disable the button when the form is invalid or after the user clicks it, but not both at the same time? How can I incorporate two statements inside the quotes for this purpose? I attempted the following code, but it didn't w ...

Completely shrink the middle row first when resizing the browser before shrinking the other rows

Utilizing a simple three row structure: <div class="EditorHeaderWrapper"> <h1>Title</h1> </div> <div class="EditorMainRowWrapper"> // Content of the main row goes here </div> <div class="EditorFooterWrapper"> ...

Having trouble dividing an HTML file?

Currently, I am working on creating a very basic web page that is divided into two parts. Each part will have its own HTML file: Welcome.html & Welcome.css: <html> <head> <link rel="stylesheet" type="text/css" href="Welcom ...

How to trigger a JavaScript function using a link in CakePHP?

When working with Html, <a href="some_url"> Contact Seller </a> In the realm of Cakephp, <?php echo $this->Html->link('Contact Seller', array('controller'=>'pages', 'action'=>'conta ...

How come my CheerpJ web page displays the loading screen but fails to function properly?

I have recently started using CheerpJ and went through the getting started tutorial. Despite following all the steps, I encountered an issue where my webpage only displayed the CheerpJ loading screen (the rotating circle) without running my app. Can anyo ...

Creating a magical transformation for the bootstrap carousel

Trying to create a bootstrap wizard with a carousel and disable auto-scrolling by setting bs-interval to "false" without success. Here is my code: <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" ...

Discovering the art of line breaks

Imagine I have a random block of text displayed in a single line, like this: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Due to various reasons such as width settings or text-zoom, the text may display as two or more lines on the viewer&apos ...

What is the reason for the ul selector not functioning in the attached CSS file?

I attempted to create a navigation bar by using the code below. <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css"> </head> <body class="background"> <ul> <li>Home</li> <li>Ne ...

Align a series of items in the center while also ensuring they are left-justified

Issue Description : I am facing a problem with centering inline-block elements. When the elements exceed the width of a single line, Action Required : I want them to be justified to the left. I have tried using flex boxes and other methods, but I can ...

Identifying and locating white-colored text within an HTML document

My HTML file has the following structure: <HTML> <HEAD> <style> .secret { background-color: black; color: black; } </style> </HEAD> <BODY ...

Creating a Modal Dialog with Justified Tab and Dropdown Using Bootstrap 4.1

I am struggling with Bootstrap 4.1 as I try to align content to the right side. Specifically, I have a Navigation Bar that triggers a Modal Dialog containing Tabs. The dropdown menu on the far right of the Tab is what I want to justify to the right. Here a ...