Tips for positioning buttons in a circular arrangement around an image

I am having trouble creating a responsive menu around a circular image. When the screen resolution changes, the buttons do not stay aligned next to the circle picture and their position shifts. How can I ensure that these image buttons stay aligned with the circle image and do not scatter across the screen? Thank you!

<div id="container">  
<div id="button1"><a href=""><img src="http://menu.bridge-network.ro/images/button1.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button1b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button1.png'" /></a></div>
<div id="button2"><a href=""><img src="http://menu.bridge-network.ro/images/button2.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button2b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button2.png'" /></a></div>   
<div id="button3"><a href=""><img src="http://menu.bridge-network.ro/images/button3.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button3b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button3.png'" /></a></div>
<div id="circle"><img src="http://menu.bridge-network.ro/images/circle.png"></div>
<div id="button4"><a href=""><img src="http://menu.bridge-network.ro/images/button4.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button4b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button4.png'" /></a></div>
<div id="button5"><a href=""><img src="http://menu.bridge-network.ro/images/button5.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button5b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button5.png'" /></a></div>

CSS:

body {
    background-color: black;
}
#container{
  clear: both;
  padding-top: 20px;
  text-align:center;
  position: relative;
  text-align:center;
}
#circle {
position:relative;
width:600px;
margin:auto;
z-index:1;
}
#button1 {
position:relative;
margin:auto;
z-index:2;
}
#button2 {
position:relative;
z-index:3;
float: left;
top:120px;
left:420px;
}
#button3 {
position:relative;
z-index:4;
float: right;
top:120px;
right:420px;
}
#button4 {
position:relative;
z-index:5;
float: left;
left:520px;
bottom:40px;
}
#button5 {
position:relative;
z-index:6;
float: right;
right:520px;
bottom:40px;
}

http://jsfiddle.net/dqba73u8/4/

Answer №1

Recently, I came across something similar to this! Utilizing media queries can also be effective, but personally, I find adjusting percentages dynamically to be a simpler solution!

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
</head>

<style>
    body {
        background-color: black;
    }
    #container{
        padding-top: 20px;
        text-align:center;
        position: relative;
        top:50px;
    }
    #circle {
        max-width:600px;
        margin:0 auto;
        width:90%;
        position:relative;
        display: block;
        text-align: center;
    }
    #your_center {
        width:50%;
        max-width:400px;
        margin:0 auto;
        text-align: center;
        position: relative;
    }
    #your_left_top, #your_left_bottom, #your_right_top, #your_right_bottom {
        max-width:200px;
        text-align: center;
        width:60%;
        position: absolute;
    }
    #your_left_top  {
        right:98%;
        bottom:55%;
    }

    #your_left_bottom  {
        right:75%;
        bottom:0;
    }
    #your_right_top  {
        left:96%;
        bottom:55%;
    }

    #your_right_bottom  {
        left:74%;
        bottom:0;
    }

    #button1 {
        max-width:200px;
        text-align: center;
        width:50%;
        position: relative;
        left:25%;
        top:-17%;
    }

     #button2, #button3, #button4, #button5, #button6, #button7 {
        max-width:200px;
        width:100%;
    }
    #circle img, #button1 img,#button2 img, #button3 img, #button4 img, #button5 img, #button6 img {
        position: relative;
        width:100%;
    }


</style>
<body>
    <div id="container" class="cf">

        <div id="your_center">
            <div id="your_left_top">
                <div id="button2"><a href=""><img src="http://menu.bridge-network.ro/images/button2.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button2b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button2.png'" /></a></div>
            </div>
            <div id="your_left_bottom">
            <div id="button4"><a href=""><img src="http://menu.bridge-network.ro/images/button4.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button4b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button4.png'" /></a></div>
            </div>
                <div id="button1"><a href=""><img src="http://menu.bridge-network.ro/images/button1.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button1b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button1.png'" /></a></div>
            <div id="circle"><img src="http://menu.bridge-network.ro/images/circle.png" /></div>
            <div id="your_right_top">
                <div id="button3"><a href=""><img src="http://menu.bridge-network.ro/images/button3.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button3b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button3.png'" /></a></div>
            </div>
            <div id="your_right_bottom">
                <div id="button5"><a href=""><img src="http://menu.bridge-network.ro/images/button5.png" onmouseover="this.src='http://menu.bridge-network.ro/images/button5b.png'" onmouseout="this.src='http://menu.bridge-network.ro/images/button5.png'" /></a></div>
            </div>
        </div>
    </div>
   </body>
</html>

Answer №2

Start implementing media queries from the following breakpoints:

@media only screen and (max-width: 1600px) {
  #button2{
    left: 24%;
  }
  #button3{
    right: 24%;
  }
  #button4{
    left: 29%;
  }
  #button5{
    right: 29%;
  }
}
@media only screen and (max-width: 1500px) {
  #button2{
    left: 21%;
  }
  #button3{
    right: 21%;
  }
  #button4{
    left: 28%;
  }
  #button5{
    right: 28%;
  }
}
@media only screen and (max-width: 1500px) {...}
@media only screen and (max-width: 1400px) {...}
@media only screen and (max-width: 1300px) {...}
@media only screen and (max-width: 1200px) {...}

For an example, check out this jsfiddle demo.

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

Dynamic VueJS HTML element selection depending on a condition

While working with Vue JS, I have the capability to do <h1 v-if="someCondition">MY TITLE</h1> Is it possible to determine the element type based on a certain condition? For instance, depending on someCondition, I would like my title to be ei ...

Arranging Bootstrap grid elements side by side

When setting up a webshop, I am organizing products into col-md-3 class divs. However, in mobile view, these divs are stacked on top of each other. I would like to have 2 divs displayed side by side when viewing on a mobile device. How can I achieve this? ...

Is it considered a bad practice to use the record ID on a <tr> element for an editable row within a table?

I am in the process of using jQuery to create a feature that allows users to edit a HTML table containing category names. Currently, I have successfully populated my table using PHP/MySQL. While researching on jQuery - Edit a table row inline, I came acr ...

What could be causing the CSS height percentage to malfunction?

I'm having trouble with some basic CSS that uses percentages. I've labeled everything and checked my code, but it still isn't working properly. Here's the CSS code snippet: .BoxHeight { height: 100%; } #Box { margin-top: 0%; mar ...

refreshing the page following retrieval of data through ajax

I've encountered an issue with using ajax to dynamically fetch data. Whenever I refresh the page, the fetched data disappears. Is there a solution to keep the data intact even after refreshing? Here's an example of my current page setup: <ht ...

Contrast the text within two div elements using jQuery and modify the color of any identical words

i have a pair of div's with sentences inside first div: i keep an expensive pen in my pocket. second div i own an expensive watch. given the above two divs, I aim to compare the sentences and identify the common words present in both. ...

Automated video and image gallery - with a twist!

While searching for a (jQuery) video/image gallery to incorporate on my website, I came across several available options. However, I am specifically looking for one that, when set to "autoplay" mode and reaches a video file, will automatically play the ent ...

Clicking on the Submit button of the post form simply refreshes the page

Every time I try to submit values from an HTML form, the page reloads without any changes. I've double-checked the routes and controller, but everything seems correct. Solution <div class="panel-body"> @if (session('status')) ...

Angular JS: Changing Byte Array into an HTML File

I created an HTML file using ASPOSE workbook and stored it in a memory stream in C#. Now, I am trying to show this HTML file in an Angular JS environment within the Div element. C# Snippet: wb.Save(htmlMemoryStream, new HtmlSaveOptions() { IsExportComment ...

Activate the mouseenter event as soon as an animated element makes contact with the cursor

As I venture into the world of web development, I am currently working on creating a game where the main objective is to avoid touching moving circles with the cursor. My approach involved using a mouseenter event as shown in the JSFiddle example below: $ ...

Display/conceal within a jQuery fixed navigation bar (center-aligned)

I am facing challenges with creating a sticky menu that shows/hides with a click button. Considering abandoning the show/hide feature altogether and rebuilding it from scratch in the future. Two major problems I have identified: How can I make the sho ...

Positioning the footer to sit at the bottom of my webpage, leaving a pleasing margin at the top

One technique I frequently use to ensure my footer stays at the bottom of my page is by utilizing an empty div. Here's how the code looks: <body> <div id="canevas"> <article>My website's content</article> ...

"Exploring the magic of product galleries: A behind-the-scenes look at how websites create images

Have you ever wondered how this website creates the customization effect in its gallery? When you adjust the color, stones, or other attributes of the ring, it appears as though a new image is being generated. (click Customize) Do you believe they have a ...

What is the best way to hide the jQuery modal I created?

Hello everyone! Currently, I am working on coding a simple JS modal that can be opened and closed smoothly. The issue I am facing is related to adding a click function to (.black-overlay) in order to fade out everything and close the modal. <div class ...

What is the method in jQuery to add a left alignment style to every element on the page?

I need jQuery to automatically add style="text-align: left;" to all elements throughout my webpage. My initial approach would be something like this: $('everything-in-the-page').each( ... However, I am a bit unsure about how to properly target ...

Using AngularJS to handle error validation for dropdowns and select elements that will redirect using the ng

Currently, I am utilizing angularjs's ng-href along with a select HTML element containing ng-model. The ng-href is being used to link to the "selectedItem" from ng-model. However, I have encountered difficulty in validating or displaying an error mess ...

Creating a visual feast: A guide to crafting a stunning image gallery

Is there a way to ensure all the pictures in a table are the same size, orientation, and inline? Currently, my images vary in size and rotation. The CSS I have applied is styling only the first image differently from the rest. Any help is appreciated! CSS ...

The functionality of jQuery date picker and time picker is compromised when the fields are generated dynamically

I am currently utilizing the jQuery code below to dynamically create multiple input fields, which include time pickers and date pickers. However, I am encountering an issue where they are not functioning as expected. $('#add_another_event').clic ...

The HTML output is essential for creating the content of a Bootstrap carousel

Is there a way to populate my bootstrap carousel with the content of an HTML page instead of images? I attempted to create a div and use CSS to load the contents from ac1_div using content:url(carousel_content.html), but it was unsuccessful. <!-- our ...

What is the best way to set the text color of cell data in a mat-table to white for the entire row when the row is selected as

Is there a way to change the text color when a row is selected in my application? I have already figured out how to change the background color of the row, but how can I target the text within the cells? I'm considering using a similar approach to th ...