Spacing between a pair of jQuery datepicker panels

https://i.sstatic.net/Xnbh1.png

Is there any way to add spacing between two tables inside the jquery date picker with a common header? I've tried various solutions like adding padding to the parent div, but haven't been able to fix it. Can anyone provide assistance?

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
....(code continues)....

Answer №1

Apply the following CSS code:

.ui-datepicker-multi-2 .ui-datepicker-group {
    width: 48%;
    margin: 0 1%;
}

This code overrides the default styles of jquery-ui without using important keyword.

For a better visual representation, view the snippet in full screen mode.

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
  /* Custom CSS Styles */
  .ui-widget-content .ui-state-default,
  .ui-widget-header .ui-state-default,
  .ui-button,
  html .ui-button.ui-state-disabled:hover,
  html .ui-button.ui-state-disabled:active {
    background: 0 !important;
    border: 0 !important;
    color: #9c9c9c !important;
    font-weight: bold;
    text-align: center !important;
    white-space: no-wrap;
    font-size: 10px;
  }
  
  table {
    border-collapse: collapse !important;
    margin: 0;
  }
  
  .ui-datepicker-multi-2 .ui-datepicker-group {
    width: 48%;
    margin: 0 1%;
}
  
  .ui-datepicker-multi .ui-datepicker-group table {
    width: 100% !important;
  }
  
  /* Additional Styles */
  .ui-datepicker-unselectable.ui-state-default {
    display: none;
  }
  
  .ui-state-range {
    background-color: #FBD2D3 !important;
    color: #fff !important;
  }

  /* Other styles go here... */

</style>
<input type="text" id="flexibledates" />
<input type="text" id="flightdeparture" />
<script>
  // JavaScript logic for datepicker functionality
  $(function() {

    // Datepicker setup for 'flexibledates' input field
    $('#flexibledates').datepicker({
      changeMonth: false,
      numberOfMonths: 2,
      dateFormat: 'D, d MM',
      dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
      beforeShow: function(input, inst) {
        insertMessageStartDate();
      },
      onSelect: function(selectedDate) {
        var selectedDate = $("#flexibledates").datepicker("getDate");
        if (selectedDate != null) {
          $('#flightdeparture').datepicker('option', 'minDate', selectedDate).datepicker('refresh');
        }
      }
    });

    // Datepicker setup for 'flightdeparture' input field
    $('#flightdeparture').datepicker({
      changeMonth: false,
      numberOfMonths: 2,
      dateFormat: 'D, d MM',
      dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
      beforeShow: function(input, inst) {
        insertMessageEndDate();
      },
      onSelect: function(selectedDate) {
        $('#flexibledates').datepicker('option', 'maxDate', $(this).datepicker('getDate'));
      }
    });

    // Functions to insert messages for start and end dates
    function insertMessageStartDate(message) {
      clearTimeout(insertMessageStartDate.timer);

      if ($('#ui-datepicker-div .ui-datepicker-calendar .ui-state-default').is(':visible')) {
        $('.ui-state-default').after('<span class="lowTicketValue">' + 45555 + '</span>');
      } else {
        insertMessageStartDate.timer = setTimeout(insertMessageStartDate, 10);
      }
    }

    function insertMessageEndDate(message) {
      clearTimeout(insertMessageEndDate.timer);

      if ($('#ui-datepicker-div .ui-datepicker-calendar .ui-state-default').is(':visible')) {
        $('.ui-state-default').after('<span class="lowTicketValue">' + 45555 + '</span>');
        
        $("#ui-datepicker-div td").on({
          mouseenter: function() {
            $(this).prevAll("td:not(.ui-datepicker-unselectable)").addClass("highlight");
          },
          mouseleave: function() {
            $("#ui-datepicker-div td").removeClass("highlight");
          }
        });
      } else {
        insertMessageEndDate.timer = setTimeout(insertMessageEndDate, 10);
      }
    }
  });
</script>

Update: To make changes in the layout, modify the CSS code as follows and view it in full screen:

.ui-datepicker-multi .ui-datepicker-group table {
    width: 96%; /* Update: You don't need !important anymore */
    margin: 4%;
}

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

/* Remaining styles remain unchanged */

Answer №2

If you're looking to style a date picker using CSS, here's a snippet you can experiment with:

 .datepicker{
    &.datepicker-orient-bottom{
        margin-top:10px;
    }
    &.datepicker-orient-top{
        margin-top:-10px;
    }
 }

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

Exploring the functionalities of radio buttons and arrays in a Javascript experiment

Currently delving into the world of Javascript and struggling to wrap my head around creating a test using only pure Javascript (no jQuery). The goal is to: Present users with a question and provide radio button options for selection. Allow users to cho ...

Setting a fixed row height for Material-UI tables in ReactJS, even when the content is long

I'm currently working on a listing component using the material UI table in ReactJS. Within this table, I have a ResumeUrl field that can span over 3 or 4 lines, but I need to limit it to just 2 lines with the rest of the content being represented by ...

"Troubleshooting the lack of background image display in Next.js when using

Can anyone help me figure out why my background image disappears when I add a linear gradient? It shows up fine without the gradient, but as soon as I include it, the image vanishes. <div className="hero" style={{background: "linear-grad ...

The menu is about to receive some custom styling

I have come across a webpage where I need to make some modifications, but I am unable to locate the script responsible for applying the inline style. This issue only seems to be occurring on the mobile version with the dropdown menu. <div class="is-dri ...

The HTML marquee element allows text to scroll sideways or

Has the html marquee tag been phased out? If so, what are the current alternatives available for achieving a similar effect on modern browsers? I am looking to implement a basic marquee effect on my Joomla page. ...

Tips for seamlessly placing a div with a background image within a parent container, all while preventing any scrolling issues as the child div rotates

I created a simple demo featuring a square image with rounded corners to give it a circular appearance. The image rotates slowly, but as it moves diagonally, the horizontal width fluctuates, causing the parent container to resize. I want the parent contain ...

Issue occurs when a circle element is not following a div element on mouse

Currently, I have implemented some jQuery code that instructs a div named small-circle to track my cursor movement. I discovered how to accomplish this by referencing a thread on stack overflow. I made slight modifications to the script to suit my specifi ...

I am having trouble getting the color, metalness, lights, and shaders to work properly in Three JS on my

I attempted to create a simple code using Three.js for a red colored torus with a point light and a textured surface, but unfortunately, all I achieved was a black torus that rotates. It seems like the elements in this code are not functioning as expecte ...

Inconsistency with Mobile Viewport Problem

Apologies for the chaos below, but I've spent quite some time attempting to fix this on my own. It's time to surrender and seek assistance! Here are some screenshots to illustrate the issue: The problem is that sometimes the webpage functions c ...

"Upon choosing a file using the HTML input file multiple element, a triggered event

After selecting multiple files using the input type="file" HTML element, I am eager to start uploading them. Can you tell me which event I should use to execute code immediately after finalizing my file selection? This is what my HTML code looks like: &l ...

I would like to modify the text color of a disabled input field

I need to adjust the font color of V1, which is a disabled input field. I want to make it darker specifically for Chrome. Any suggestions on how I can achieve this? https://i.sstatic.net/kioAZ.png Here's my HTML code: <mat-form-field appearance= ...

How to Align Bootstrap 4 Navbar Brand Logo Separate from Navbar Toggler Button

Can anyone help me with center aligning navbar-brand? When I right align navbar-toggler for mobile devices, it causes the logo to be off-center. Is there a way to independently align these two classes, and if so, how can I achieve this? <nav class="n ...

Creating a layout with two columns using CSS and setting the height to

Currently, I am dealing with a two-column layout where both columns have a height of 100%. Everything seems to be working fine in that aspect. However, an issue arises when the content in the left column expands due to a dropdown menu being activated. Be ...

Building CSS Using TagBuilder in .NET Core

Can you provide guidance on utilizing the Tag Builder CSS Class? I am interested in integrating it into a style class .custom-image { max-width: 100%; max-height: 100%; padding: 0; background-color: white; } TagBuilder image = new TagBuilder("img"); Wh ...

Problem with CSS animations in IE10

I've encountered a problem with a specific section of a website I created. This section functions perfectly on all browsers and older versions of Internet Explorer, but not on the latest versions. It seems that IE no longer supports [IF] statements in ...

Could we incorporate a backwards typewriter animation?

Is there a way to delay this animation for 2 seconds before playing in reverse? I came across this online and made some edits, but I'm still new to this (early stages). Can this be achieved using CSS, HTML, and JavaScript? I plan to use this as an ale ...

-webkit-box has no shrinking effect

I'm attempting to design a dynamic layout using the -webkit-box property. While the box adjusts properly when the children grow, I've noticed that when the children are resized smaller, the box remains in an enlarged state, especially with multi ...

I'm having trouble aligning this div in the center of the screen. It looks like the position is slightly off

<!DOCTYPE html> <html> <head> <style> body { background-color: #7a64fa; } .container { background-color: #ffffff; position: fixed; top: 50%; left: 50%; margin-top: -50px; ...

Maximizing the potential of jquery.animate when implementing page scroll following an ASP.NET postback with MaintainScrollPositionOnPostback

I've been working on implementing a "Page scrolling animation" that triggers after a user clicks on my ASP.NET button. Here's the approach I took: String script = "<script type=\"text/javascript\">" + "\n" + ...

Enhancing mobile user experience with Bootstrap 4's responsive design

Currently, the footer appears like this in full-screen mode: https://i.sstatic.net/ygI9G.png However, I need it to be stacked and centered when in mobile view. I seem to be having trouble achieving this effect. <footer id="footer"> <d ...