When the page is minimized, the alignment of Bootstrap divs becomes distorted

Check out my code on CodePen: http://codepen.io/auble220/pen/rOPBKP. I added media queries in this version: http://codepen.io/auble220/pen/avyZZE. Although it's not too bad, I'm sure there's a more efficient way to achieve this. I attempted to use Bootstrap's clearfix class, but it didn't make a difference. Here is the code snippet for that section:

html:

<div id="brkSesDiv" class="row">
  <div id="breakDiv" class="col-md-6 text-right">
    <button class="plusMinus" id="plus1">+</button>
    <h1 id="breakLen">05</h1>
    <button id="minus1" class="plusMinus">-</button>
    <h4>break length</h4>
  </div>
  <div id="sesDiv" class="col-md-6 text-left">
    <button id="plus2" class="plusMinus">+</button>
    <h1 id="sesLen">25</h1>
    <button id="minus2" class="plusMinus">-</button>
    <h4>session length</h4>
  </div> 
</div>

css:

#brkSesDiv {
  margin: 30px 0 0 0;
  height: 100px;
  width: 350px;
  margin: auto;
}
#breakDiv {
  display: inline;
}
#breakLen {
  display: inline;
}
#sesDiv {
  float: left;
}
#sesLen {
  display: inline;
}

Answer №1

Here is a demonstration of how you can prioritize mobile functionality first and then customize it according to your requirements.

I recommend avoiding the mixing of classes/IDs with structural elements like containers/rows/columns, except for pure styling purposes (such as color, text, etc.), as this can impact the grid layout. Instead, you can place your content within these columns for better results in most cases.

Having a fixed width is not essential, so I have eliminated that and placed everything within rows/columns without combining them:

#brkSesDiv {
  margin: 30px 0 0 0;
  height: 100px;
  width: 350px;
  margin: auto;
}

Check out the working example Snippet.

var sec = 0;
var min;
var breakLenCount = 5;
var sesLenCount = 25;
var breakTimer;
var timerRunning = false;

$(document).ready(function() {
  // Add and subtract event functions
});

// Timer functions
body {
  font-family: Arial, sans-serif;
}
// CSS Styles
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
  <div class="text-center">
    <h1 id="pTimer">Pomodoro Timer</h1>

  </div>
  <div class="row">
    <div id="brkSesDiv">
      <div class="col-xs-6 text-right">
        <div id="breakDiv">
          // Break session elements
        </div>
      </div>
      <div class="col-xs-6 text-left">
        <div id="sesDiv">
          // Session elements
        </div>
      </div>
    </div>
  </div>
  <div id="timer" class="text-center">
    <div id="time">
      <h1 class="title">Session</h1>

      <h1 class="title"><span id="min">25</span>:<span id="sec">00</span></h1>

    </div>
  </div>
</div>

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

Align the middle row using CSS Grids

I am working on creating a grid layout with a size of 4x3, and I would like the second row to be centered as the top row contains four elements. Here is an example of what I am trying to achieve: https://i.sstatic.net/FnN7s.png Check out the demo code b ...

Manipulating content with JavaScript in Internet Explorer using the outerHTML property is a powerful

Encountering an Issue with outerHTML in IE Browser If I try the following: txt = "Update Complete!"; msg = sub.appendChild(d.createElement("p")); msg.outerHTML = txt; It works without any problem. However, if I use: txt = "1 Error:<ul><li> ...

Using jQuery to load content into a jQuery UI dialog box

I am looking to implement a pop-up that displays content from another asp page. To achieve this, I am using jquery.load to load the page into a div and jquery-ui.dialog. This is my code: <div id="dialog"></div> Inside the document ready fun ...

The Final Div Fluttering in the Midst of a jQuery Hover Effect

Check out my code snippet here: http://jsfiddle.net/ZspZT/ The issue I'm facing is that the fourth div block in my example is flickering quite noticeably, especially when hovering over it. The problem also occurs occasionally with the other divs. Ap ...

Retrieve information from a MySQL database and integrate it into a different application

This php script is used to generate a table with a "book" button next to each row. The goal is to extract the values of "phase" and "site" from the specific row where the "book" button is clicked, and transfer them to another form (in "restricted.php") fo ...

Is there a way to insert an attribute in HTML without simply appending it to the end of the tag?

I've been working on incorporating the code snippet below that I found in an angularjs table sort function. In the code, you can see the ts attributes being added to the html. However, this method is not suitable for hosting on Salesforce. Can anyone ...

Issue with Bootstrap 4 progress bar malfunctioning in popover due to CSS property restrictions within the popover container

The following code functions correctly in the body area: <div class="progress" style="height: 25px;"> <div class="progress-bar" style="width: 30%;" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"> </div> & ...

Tips for rotating individual letters within a sentence on popular web browsers, including Chrome

Can you make a sentence appear with each individual letter rotating and getting larger? This is my approach: I decided to split the sentence into separate span elements, one for each letter. Then I used CSS transform -webkit-transform to animate the lette ...

JavaScript code may fail to load on initial page load

My JavaScript function utilizes ajax and is triggered when a button is clicked. Oddly, the function works perfectly if you visit the page for a second time, but fails to work on the first visit. I've attempted to include window.onload, document.onlo ...

Utilizing useState for React Data Picker

I recently attempted to implement the React Data Picker in my React project using npmjs. However, I encountered an issue when trying to import useState from import React, { useState } from "react"; The error message displayed: 'useState&a ...

I want to learn how to display the rupee symbol instead of the default dollar symbol in AngularJS for specific currency symbols

When using 'currency' in AngularJS, I noticed that a dollar symbol is displayed. How can I change this to show the required currency symbol based on different requirements? Currently, I am looking for information on how to display a rupee symbol ...

Can CSS be used to generate a grid or error image in Internet Explorer?

Can an image like this be created using CSS in Internet Explorer? I attempted to use filter: progid:DXImageTransform.Microsoft.gradient, but it was unsuccessful. ...

Interacting with dynamically loaded HTML content within a div is restricted

On my main HTML page, I have implemented a functionality that allows loading other HTML pages into a specific div using jQuery. The code snippet looks like this: $('.controlPanelTab').click(function() { $(this).addClass('active').s ...

Saving users' dark mode preference on my website

I recently implemented a dark mode feature on my website. However, I noticed that when I enable dark mode and then refresh the page or navigate away, the preference resets. To address this issue, I am looking to store the user's preference as a cookie ...

The background image seems to be malfunctioning

I've been attempting to recreate a similar design to this website, and while most of it is working smoothly, I'm encountering an issue with using ::before to add a background image as desired. Below is the code snippet in question: /* Section ...

Is it considered secure to encase a function within jQuery's removeClass()?

I'm currently developing a unique slider that includes a dynamic video element. With each slide transition, a new video is added to the DOM while the previous one is removed. To achieve this effect, I am utilizing CSS transitions along with a specific ...

Converting Flex Text into HTML format for seamless integration

In my application, I have the capability to configure certain pages using the RichTextEditor and then save the resulting HTML Text Flow to a database for future use... When I import the saved data into Flex using a RichEditableText, everything appears as ...

When a link is entered into a textbox, the desired outcome is for it to display as a clickable link when viewed on a web page

I am looking to create a text box where I can input a link, store it in a MySQL database using PHP, and then display the link on a PHP page so that it behaves like the original link. For example: <form> <input type="" name="text" /> <input ...

How to achieve smooth transitions in CSS3 with dynamic height changes?

Currently, I am in the process of designing a unique layout. The main challenge lies in toggling between two classes for a div element, one of which has a height of 0px. To achieve this, I have successfully utilized CSS3 animations that effectively scale t ...

Guide on generating angular <popover-content> programmatically

My goal is to generate angular elements dynamically. While static creation works perfectly fine, I am facing challenges when trying to create them dynamically using data. For instance: <div> <popover-content #pop1 title=" ...