Utilizing CSS and HTML to center elements

My jquery datepicker is set up to display color dots above certain days to represent information for that day.

I'm running into some CSS issues.

I'm trying to center the dots with the corresponding numbers, but when I do that, the days with dots don't align horizontally with the other days. I've included a photo to illustrate the problem. The days 22, 23, 24, 28, 29, 16, 17 with dots are not aligning with the rest of the days.

Any suggestions on how to properly align the days with dots?

https://i.sstatic.net/00fB8.jpg

<td class=" " data-handler="selectDay" data-event="click" data-month="3" data-year="2020"><a class="ui-state-default" href="#">27</a></td>
<td class=" " data-handler="selectDay" data-event="click" data-month="3" data-year="2020"><a class="ui-state-default" href="#">28</a>
    <div class="dot-container">
        <div class="dot orange"></div>
        <div class="dot black"></div>
        <div class="dot red"></div>
        <div class="dot blue"></div>
    </div>
</td>
<td class=" " data-handler="selectDay" data-event="click" data-month="3" data-year="2020"><a class="ui-state-default" href="#">29</a>
    <div class="dot-container">
        <div class="dot black"></div>
        <div class="dot orange"></div>
        <div class="dot yellow"></div>
        <div class="dot red"></div>
    </div>
</td>

.ui-state-default{
    text-align:center !important;
}

.dot-container {
    text-align: center;
}

.dot{
  width: 7px !important; 
  height: 7px !important;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;

}

@media (max-width: 450px) { 
    .dot{
         width: 5px !important; 
         height: 5px !important;
         border-radius: 50%;
         display: inline-block;
         margin-right: 2px;
    }
 }
.red{
   background-color: red !important;
}
.blue{
   background-color: blue !important;
}
.yellow{
  background-color: yellow !important;
}

.green{
     background-color: green !important;
}
.black{background-color: black !important;}
.orange{background-color: orange !important;}


.ui-datepicker .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
    border: none !important;
    background-color: #fff !important;
    padding: 10px 0 !important;
    max-width: 40px;
    max-height: 40px;
    margin: 10px 0 !important;
    margin-top: 10px !important;
    margin-left: 0px !important;
    margin-right: 0px !important;
    margin-bottom: 2px !important;
}


I attempted to add the attribute position: absolute to the dot-container class, but this caused all the day numbers to align differently.

Answer №1

To align content vertically within a td element, utilize the CSS property vertical-align

td {
    vertical-align: top;
}

Answer №2

Seems like a breeze

td{
    position: relative;
}
.dot-container{
    position: absolute;
    left: 0;
    top: 100%;

}

Another method: (inspired by @saran)

td {
    vertical-align:top;
}

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

Exploration of the "display: none;" property and loading of content

I am struggling to find concrete information on how "display: none;" affects content loading. I have always believed that certain browsers do not load external resources within content that is styled with "display: none". Is this still inconsistent across ...

An internal server error has occurred within the asp.net framework, resulting in

Seeking Solution: Currently, I am in the process of developing an application where I have implemented an HTML select list to choose a category. Using AJAX web method, I am trying to retrieve items and their respective images based on the selected category ...

Is there a way to make a link clickable but also prevent another link from being activated when clicked?

Have you ever utilized #link to navigate to a specific section on a webpage? You can also incorporate animate and scrollTop() to ensure a smooth scroll. However, when the #link (Hash link) is situated in the navigation menu, it must be structured as exampl ...

Struggling to resize tables in React Material-UI

Here is my SandBox link for reference: https://codesandbox.io/embed/material-demo-j6pz9?fontsize=14&hidenavigation=1&theme=dark I am attempting to organize content within a card using an inline grid display to have them appear side by side. I unde ...

Is it possible to trigger a JavaScript function by manipulating the URL of an HTML page?

Imagine this scenario: You have an HTML page located at example.com/test.html that contains several pre-defined JavaScript functions, including one named play(). How can I add JavaScript to the URL in order to automatically trigger the play() function wh ...

Problems with Displaying Facebook Ads on Mobile Web

Currently, I am incorporating Facebook Audience Network (MobileWeb-beta) for advertisements on my mobile website. However, the 320x50 HTML source code is not displaying the ad across the width of the mobile screen as intended; instead, it appears smaller ( ...

Finding the actual path in any scenario using JavaScript ($.ajax)

Here is the structure of my project: Sil -> css -> js -> clients -> index.php -> response.php index.php I am facing an issue related to the folder 'clients'. My website URL can have different va ...

Using ajax to send an array to PHP

I have an array named "heart" that is being sent via ajax... var heart = [31,32,33,34,35,36,37,38,39,42,43]; // Sending this data via ajax to php file/ $.ajax({ type: "POST", data:{ 'system': heart }, url: "login-function.php", success: f ...

Can you control the order of rendering for specific divs in a ReactJS application?

I need assistance with developing a mobile app using ReactJS and react bootstrap that can dynamically resize itself based on the screen size. One specific part of the app requires calculations to determine its dimensions based on the remaining space on the ...

The bottom of the page refuses to remain anchored

I've exhausted all possible solutions and my footer just refuses to stay at the bottom of the page. Working with Opencart has made it challenging for me to pinpoint the root cause, leaving me utterly perplexed. The issue persists on pages with minim ...

Encountering an error with the message "SyntaxError: missing ; before statement" while attempting to utilize the Google Place Search

Lately, I've been encountering a 'SyntaxError: missing ; before statement' error while attempting to execute this ajax code in order to retrieve all nearby ATMs within a 1 km radius. var url = "https://maps.googleapis.com/maps/api/place/nea ...

Retrieve JSON from a JSP page and access the data using AJAX

Is there a way to automatically fill a form in a JSP page based on the field codigo_caso? When this field is blurred, I want to send a JSON-like String to another JSP that retrieves the necessary data to complete the form. I have tested the page and it su ...

Verifying the accessibility of a website using JQuery/Javascript

I am attempting to use JavaScript to ping a website and display the result. Unfortunately, I have not had any success with this JSFiddle: https://jsfiddle.net/yyjowtru/ Although I believe I am close to achieving the desired outcome, changing the URL in t ...

Generate code in Yii2 using the active form

This is the code I am using in Yii2: <?= $form->field($model, 'username')->label(false); ?> <?= $form->field($model, 'password')->label(false); ?> It produces the following output: <div class="form-group fi ...

Cross-platform mobile browsers typically have scrollbars in their scrollable divs

I have successfully implemented scrollable div's on a page designed for tablets running Android 3.2+, BlackBerry Playbook, and iOS5+ (except iPad 1). However, I would like to add scrollbars to improve the user experience. For iOS5, I can use the suppo ...

Generate a text string by choosing options from a form

Greetings! I have a form for creating a file, where the file name is determined by user selections. It's similar to "display text as you type" mentioned here, but my form includes radio buttons in addition to a textbox. For example: Textbox: "Name gi ...

I am having issues displaying my background image

I'm experiencing an issue where my background image isn't displaying correctly. Here is the CSS code I'm using: body { background-image: url('img/bg.png'); background-repeat: no-repeat; } ...

Is there a way to conceal the scrollbar in the mobile view (on a mobile device or emulator) in a React application without disrupting the scrolling functionality?

I am looking to conceal the scrollbar on mobile devices throughout my app while still allowing users to scroll. I have attempted to hide the scrollbar using CSS properties like scrollbar, scrollbar-thumb, scrollbar-thumb:hover, and scrollbar-track. This ...

The functionality of Bootstrap's Modal feature seems to be malfunctioning

I'm attempting to test the sample modals for my project, but even the codes from jfiddles are not working for me. When I click the button, it only gives me a dimmed window. I have also tried searching on Google for a solution, but to no avail. Below ...

Activate night mode in ElementPlus using CDN

Is there a way to set the theme to dark in ElementUI + Vue when using CDNs instead of npm? <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" /> ...