Arrange divs on the screen in a specific formation

I am exploring ways to position specific divs in the middle of the screen to create a pearl necklace-like shape. The desired shape is as follows:

     0 0
   0     0
   0     0 
    0   0
      0
      0

My aim is to achieve this using jQuery on a mobile Ionic app. I want these "beads" to be centered on the screen. Below is the HTML code I currently have for my view, which I can modify if necessary:

<ion-view view-title="Pray the Rosary" id="prayer">
  <ion-content>
    <div id="prayer-content">
    <div id="current">Sorrowful Mysteries</div>
    <div ng-click="play()" id="play">Begin</div>
    <div ng-click="pause()" id="pause">Pause</div>
      <div class="bead" ng-class="inactive" id="bead14"></div>
      <div class="bead" id="bead13"></div>
      <div class="bead" id="bead12"></div>
      <div class="bead" id="bead11"></div>
      <div class="bead" id="bead10"></div>
      <div class="bead" id="bead9"></div>
      <div class="bead" id="bead8"></div>
      <div class="bead" id="bead7"></div>
      <div class="bead" id="bead6"></div>
      <div class="bead" id="bead5"></div>
      <div class="bead" id="bead4"></div>
      <div class="bead" id="bead3"></div>
      <div class="bead" id="bead2"></div>
      <div class="bead" id="bead1"></div>
      <div id="cross"><img src="../img/images/cross.png" alt=""></div>
    </div>
  </ion-content>
</ion-view>

The current CSS styling:

/*Prayer content*/
#prayer-content{
  width: 90%;
  padding: 10%;
  text-align: center;
  position:relative;
}
.bead{
  border-radius: 50%;
  width: 20px;
  height: 20px;
  background: #8ee5f5;
}
.active{
  background: #006baf;
  border: 1px dashed #fff;
}
#cross{
  position: absolute;
  top: 320px;
  left: 154px;
}
#bead1{
  position: absolute;
  top: 292px;
  left: 196px;
}
#bead2{
  position: absolute;
  top: 266px;
  left: 196px;
}
#bead3{
  position: absolute;
  top: 240px;
  left: 196px;
}
#bead4{
  position: absolute;
  top: 201px;
  left: 191px;
  width: 30px;
  height: 30px;
}
#bead5{
  position: absolute;
  top: 180px;
  left: 223px;
}
#bead6{
  position: absolute;
  top: 155px;
  left: 236px;
}
#bead7{
  position: absolute;
  top: 126px;
  left: 248px;
}
#bead8{
  position: absolute;
  top: 95px;
  left: 240px;
}
#bead9{
  position: absolute;
  top: 76px;
  left: 215px;
}
#bead10{
  position: absolute;
  top: 76px;
  left: 180px;
}
#bead11{
  position: absolute;
  top: 95px;
  left: 155px;
}
#bead12{
  position: absolute;
  top: 126px;
  left: 151px;
}
#bead13{
  position: absolute;
  top: 153px;
  left: 160px;
}
#bead14{
  position: absolute;
  top: 180px;
  left: 173px;
}

While it appears fine on the iPhone view, it looks disorganized on the iPad. Is there a way to use JavaScript to ensure that the beads remain aligned at the center consistently?

Thank you for your suggestions!

JS Fiddle: https://jsfiddle.net/tetxwj8k/

Answer №1

/*Prayer content*/
#prayer-content{
  width: 128px;
  padding: 0;
  text-align: center;
  position:relative;
  margin: 0 auto;
  min-height: 489px;
  margin-top: -35px;
}
.bead{
  border-radius: 50%;
  width: 20px;
  height: 20px;
  background: #8ee5f5;
}
.active{
  background: #006baf;
  border: 1px dashed #fff;
}
#cross{
  position: absolute;
  top: 320px;
  left: 154px;
}
.bead{
  border-radius: 50%;
  width: 20px;
  height: 20px;
  background: #8ee5f5;
}
.active{
  background: #006baf;
  border: 1px dashed #fff;
}
#cross{
  position: absolute;
  top: 320px;
  left: 6px;
}
#bead1{
  position: absolute;
  top: 292px;
  left: 49px;
}
#bead2{
  position: absolute;
  top: 266px;
  left: 49px;
}
#bead3{
  position: absolute;
  top: 240px;
  left: 49px;
}
#bead4{
  position: absolute;
  top: 201px;
  left: 45px;
  width: 30px;
  height: 30px;
}
#bead5{
  position: absolute;
  top: 180px;
  left: 87px;
}
#bead6{
  position: absolute;
  top: 155px;
  left: 105px;
}
#bead7{
  position: absolute;
  top: 126px;
  left: 117px;
}
#bead8{
  position: absolute;
  top: 95px;
  left: 100px;
}
#bead9{
  position: absolute;
  top: 76px;
  left: 70px;
}
#bead10{
  position: absolute;
  top: 76px;
  left: 30px;
}
#bead11{
  position: absolute;
  top: 95px;
  left: 0px;
}
#bead12{
  position: absolute;
  top: 126px;
  left: -10px;
}
#bead13{
  position: absolute;
  top: 153px;
  left: 0px;
}
#bead14{
  position: absolute;
  top: 180px;
  left: 15px;
}
<ion-view view-title="Pray the Rosary" id="prayer">
  <ion-content>
    <div id="prayer-content">
    <div id="current">Sorrowful Mysteries</div>
    <div ng-click="play()" id="play">Begin</div>
    <div ng-click="pause()" id="pause">Pause</div>
      <div class="bead" ng-class="inactive" id="bead14"></div>
      <div class="bead" id="bead13"></div>
      <div class="bead" id="bead12"></div>
      <div class="bead" id="bead11"></div>
      <div class="bead" id="bead10"></div>
      <div class="bead" id="bead9"></div>
      <div class="bead" id="bead8"></div>
      <div class="bead" id="bead7"></div>
      <div class="bead" id="bead6"></div>
      <div class="bead" id="bead5"></div>
      <div class="bead" id="bead4"></div>
      <div class="bead" id="bead3"></div>
      <div class="bead" id="bead2"></div>
      <div class="bead" id="bead1"></div>
      <div id="cross"><img src="../img/images/cross.png" alt=""></div>
    </div>
  </ion-content>
</ion-view>

My strategy to maintain central alignment:

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

How can I arrange images vertically instead of placing them side by side?

I need help figuring out how to display multiple images in a vertical format instead of horizontally in the code below. The images are wide and take up too much space if shown side by side. My coding skills are basic, so specific guidance on where to mak ...

Exploring the capabilities of VueJs in detecting events triggered by parent components

When users click on a specific image in the Collection(parent component), my goal is to display that image in a Modal(child component). Below is the code snippet: routes.js import Home from './components/Home'; import About from './compone ...

Utilizing JSON data as a variable for handling in a Handlebars view within a Node.js/Express application

I am currently seeking a solution to display a view that includes a variable with data fetched from an API. My technology stack involves express, handlebars, and request. Here is the code for the web server's router: const express = require('ex ...

Express.js automatically sets timeouts for requests to static files

I've been facing this issue for several weeks now - after launching, Express functions properly for a few hours and then suddenly stops serving static files. The situation is as follows: GET / 304 153ms GET /js/bootstrap.min.js 200 120000ms GET /img/ ...

Choose All Box for Dynamic Tables in AngularJS

Hi everyone, I'm currently working on adding a select-all checkbox to the top of my list of checkboxes using a custom directive. I found some guidance on how to do this in a thread that I came across: https://github.com/lorenzofox3/Smart-Table/issues/ ...

Adding a class to a navigation item based on the route path can be achieved by following

I am currently working on a Vue.js project and I have a navigation component with multiple router-links within li elements like the example below <li class="m-menu__item m-menu__item--active" aria-haspopup="true" id="da ...

Safari browser not supporting CSS @property --rotate functionality

This card's animation is functioning well in Chrome, but it is not compatible with Safari and Mozilla Firefox. I suspect the issue lies with the @property --rotate, as it is no longer supported by Safari. Therefore, I am searching for an alternative ...

Retrieving input values from different input types within a div using jquery

I have a dilemma with two divs that I switch between based on whether the user wants to add single select options or multiple. Only one div is visible at a time. <div class="form-group row" id="divOptions"> @Html.Label("Choices", htmlAttrib ...

Is there a way to eliminate the menuArrow from a Select widget in gwt-bootstrap3?

In my current project, using gwt-bootstrap3, I have been attempting to conditionally remove the menu arrow from a Select box. I have experimented with various methods such as: <select:Select ui:field="fieldName" name="fieldName" b:id="fieldName" showM ...

eliminating labels from a string through recursive method

One of my challenges involves developing a function that can remove tags from an input string. For example: '<strong>hello <em>my name <strong>is</strong> </em></strong>' The desired result should be: &apos ...

Encountering an "invalid query parameter" error when making a find request with FeatherJS and ReactJS

Adding $show:true to the data below results in an error when making the find request. However, when I remove $show:true, everything works perfectly with no errors. The error message states: Invalid query parameter $show. I have attempted using differe ...

lines stay unbroken in angular

I am encountering an issue when I execute the following code: DetailDisplayer(row) : String { let resultAsString = ""; console.log(row.metadata.questions.length); (row.metadata.questions.length != 0 )?resultAsString += "Questions ...

When the table is clicked, a dynamic accordion table should appear

My current code displays a table inside another table using a PHP for loop. While I can retrieve the data successfully, I'm facing issues with the UI layout and accordion functionality. The inner table is displaying beside the outer table instead of b ...

How can one HTML form be used to request a unique identifier from the user, retrieve a record from the database, parse it into JSON format, and then populate an HTML page form using the

As someone who isn't an expert in any specific coding language, I have a knack for piecing things together to make them work. However, my current challenge is stretching my technical abilities a bit too far. Here's what I'm trying to achieve ...

Utilizing margins in CSS for various div elements

Update: I have included Javascript and Masonry tags in my project. Despite having modules of the same size, I am exploring how masonry can assist me. However, I find it a bit puzzling at the moment as I am not aiming to align elements of different sizes. I ...

Show the file name in the email signature instead of displaying the image

I'm facing a unique challenge with images in my HTML email signature. Sometimes the images are replaced by their file names on certain email hosts. Interestingly, I can't replicate this error now as the images are displaying correctly again! He ...

What are the different ways to upload files with multiple file input options?

Is there a way to upload multiple files using separate file input types or do I need to use just one input type and CTRL+click the files? My back end is written in perl. <form action="dsadsa" method="post" enctype="multipart"> <tr> ...

Issues with jQuery spinner not currently active

For quite some time, I had this code working perfectly in my Rails application: $(function () { // Modifying the link's icon while the request is in progress $(document).on('click', 'a[data-remote]', function () { ...

In TypeScript, a mapped type is not allowed to define properties or methods

My challenge involves defining an interface with keys that match a specific enum key type. However, when I attempt to declare this type, I encounter the following error message: A mapped type may not declare properties or methods. Below is the code snip ...

Content that can be scrolled within a React.Box container

I am struggling with a particular view. The columnBox I have can potentially hold a large number of items, but for some reason it's not scrolling in the view. I've already tried setting overflowY to auto, but since I don't know the exact hei ...