Customize Bootstrap 3: Resize cells within a row in a div

Is there a way to adjust the cell sizes in a row so that all characters fit and have equal heights? Currently, the row looks like this: https://i.sstatic.net/A7o4Z.png Notice how the Japanese column has small characters that don't fully fit in the cell. Also, the English column cell is shorter than its neighbor.

I'd like the row to appear as follows: https://i.sstatic.net/7cRRD.png

The background resembles a long, green rectangle.

Below is the CSS and HTML code I'm using:

<style type='text/css'>
/* For small screen */
  .row :nth-child(even){
  background-color: #FFFFFF;
}
.row :nth-child(odd){
  background-color: #D0E9C6;
}

/* For medium screen */    
@media (min-width: 768px) {
  .row :nth-child(4n), .row :nth-child(4n-1) {
    background-color: #FFFFFF;
  }
  .row :nth-child(4n-2), .row :nth-child(4n-3) {
    background-color: #D0E9C6;
  }
}

/* For large screen */
@media (min-width: 992px) {
  .row :nth-child(6n), .row :nth-child(6n-1), .row :nth-child(6n-2) {
    background-color: #FFFFFF;
  }
  .row :nth-child(6n-3), .row :nth-child(6n-4), .row :nth-child(6n-5) {
    background-color: #D0E9C6;
  }
}

.header, h1 { background-color: #FFFFFF !important}
.en-buffer  { margin-top: 10px; margin-right: 10px }
.jp-buffer  { margin-top: 10px; margin-left: 10px }
</style>

</head>

<body>

<div class="row">
  <div class="col-md-4 col-sm-6 col-xs-12 header jp-buffer"><h1>Japanese</h1></div><div class="col-md-4 col-sm-6 col-xs-12 header en-buffer"><h1>English</h1></div>
</div>
<div class="row">
  <div class="col-md-4 col-sm-6 col-xs-12 japanese jp-buffer"><ruby lang="jp">カレー</ruby><ruby lang="jp">粉<rp>(</rp><rt>こ</rt><rp>)</rp>は</ruby><ruby lang="jp">家<rp>(</rp><rt>いえ</rt><rp>)</rp>にあるの?</ruby></div><div class="col-md-4 col-sm-6 col-xs-12 english en-buffer">Do you have curry powder at your house?</div>
</div>

Answer №1

I believe the issue stemmed from the classes .en-buffer and .jp-buffer

Consider utilizing padding instead of margin...

/* Styles for different screen sizes */

.row:nth-child(even) {
  background-color: #FFFFFF;
}
.row:nth-child(odd) {
  background-color: #D0E9C6;
}

@media (min-width: 768px) {
  /* Styles for medium screens */
  .row:nth-child(4n),
  .row:nth-child(4n-1) {
    background-color: #FFFFFF;
  }
  .row:nth-child(4n-2),
  .row:nth-child(4n-3) {
    background-color: #D0E9C6;
  }
}


@media (min-width: 992px) {
  /* Styles for large screens */
  .row:nth-child(6n),
  .row:nth-child(6n-1),
  .row:nth-child(6n-2) {
    background-color: #FFFFFF;
  }
  .row:nth-child(6n-3),
  .row:nth-child(6n-4),
  .row:nth-child(6n-5) {
    background-color: #D0E9C6;
  }
}

.header,
h1 {
  background-color: #FFFFFF !important
}

.en-buffer {
  padding: 10px;
}

.jp-buffer {
  padding: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />


<div class="row">
  <div class="col-md-4 col-sm-6 col-xs-6 header ">
    <h1>Japanese</h1>
  </div>
  <div class="col-md-4 col-sm-6 col-xs-6 header ">
    <h1>English</h1>
  </div>
</div>
<div class="row">
  <div class="col-md-4 col-sm-6 col-xs-6 jp-buffer ">
    <ruby lang="jp">カレー</ruby>
    <ruby lang="jp">粉
      <rp>(</rp>
      <rt>こ</rt>
      <rp>)</rp>は</ruby>
    <ruby lang="jp">家
      <rp>(</rp>
      <rt>いえ</rt>
      <rp>)</rp>にあるの?</ruby>
  </div>
  <div class="col-md-4 col-sm-6 col-xs-6 en-buffer">Do you have curry powder at your house?</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

Modify the bg class when the checkbox is selected

Currently revamping my portfolio website and could use a hand with some jQuery code. Hoping to make a parent class react to a checkbox within it. Specifically looking to change the background color to #000 when the checkbox is checked. Struggling to figur ...

The true height is never fully accurate when a vertical scrollbar is visible

Having an issue that needs solving. I've created a simple layout, but I'm struggling with getting the sidebar and wrapper to adjust their height properly. This is how the layout looks: <div class="sidebar collapse"> <div class="sideb ...

Vue.js is utilizing a JavaScript file for routing purposes to serve as the main index

I have encountered an issue with including JavaScript files globally in my web page. When I include the script ./js/my-file.js in index.html, I receive this error in the console: Uncaught SyntaxError: Unexpected token '<' If I try to access ...

What is the best way to duplicate a CSS shape across a horizontal axis?

I am working on decorating the bottom of my page with a repeated triangle design. The image provided only displays one triangle, but I would like to extend it across the entire horizontal div. Here is a screenshot of my progress so far: https://i.stack.im ...

Visual feedback on Bootstrap button outlines when clicked

https://i.sstatic.net/A78vB.png Hello, I'm currently working on styling the border around the primary button (btn-primary) and I'm facing an issue where a light blue border appears after clicking which seems to be unaffected by adjusting the out ...

What is the process for inserting an image using nodemailer in Outlook?

I have been facing an issue while trying to send emails via Gmail using Nodemailer. The problem arises when the emails are opened on Outlook or Windows 10 Mail by the company, as I need to embed images like the logo and a background. While attaching the im ...

Which is better: CSS gradients or background images?

Years ago, I came across many CSS codes that used background-image: url(xxx.png) to mimic a gradient background filter, as only (please correct me if I'm mistaken) IE's proprietary filter could achieve a CSS gradient. In today's world - giv ...

Tips for aligning two cards in the center with Bootstrap

[site][1] [1]: https://i.sstatic.net/CmQRP.png Hey there, I'm trying to figure out how to center my two cards on the page. Can anyone help me with this? <div> <div class="card" style="width: 18rem;"> <img ...

Issue encountered while attempting to transfer data via the $.ajax method

I created a poll form using radio buttons. To submit the form, I utilized $.ajax. However, when I tried using $("#polling").serialize() to gather the data, nothing was sent or requested... Could the issue be related to the radio buttons? $(function( ...

Selenium is having trouble locating the element that is clearly visible on the HTML page

After manually inspecting and obtaining the xpath of the element, I notice it says 1 of 1. At this point, I create a unique Xpath for the element. However, despite my efforts, Selenium is still unable to locate it. Despite using Waits and confirming that ...

Does anyone know if it's possible to show an "error page" in the browser for a PHP or MySQL error?

My website dedicated to classifieds is built primarily using PHP and MySql. If an error occurs, such as when a variable cannot be found, I would like to display an error page. Is it possible to have every error redirect to the same error page? I am consi ...

Ensuring Consistent Height for a Responsive HTML Document Across Devices

My html page is facing a problem when printing from different Android devices. The page height changes dynamically based on label updates through JavaScript, and I pass this height to adjust the printed page (approximately 856x3000 pixels). However, issu ...

Explore the versatility of jQuery by utilizing multiple objects in your POST and GET requests to PHP for enhanced

I am trying to send multiple arrays to a PHP page using jQuery and retrieve results, but I am encountering an issue where the array values are not being properly passed to the PHP page. Notice: Undefined index: $name Notice: Undefined index: $type Notice ...

Styling the alignment of category menu columns using CSS

I'm looking for advice on customizing a menu in Magento. The current menu is functional, but I'm not happy with how the items are aligned on the website. Below, you'll find an image of the current menu and another one displaying my preferred ...

Guide to positioning a div in the center while implementing animations through transition and transformation using scale

Creating a popup for my React app without relying on external libraries is my current project. I am experimenting with using transition and transform with scale to size the popup dynamically based on screen size and content, then center it on the screen. ...

Guide on adding a button to a mat-table in Angular

I am looking to add a delete button or an Angular trash icon to a mat-table in an Angular application. Can anyone guide me on how to achieve this? Here is my current table code: <mat-table #table [dataSource]="ELEMENT_DATA"> <ng-container cdk ...

Experiencing issues on Chrome while switching stylesheets; any tips on avoiding this glitch?

I am currently working on designing a webpage and running into some issues with Chrome when changing stylesheets for light and dark themes. Initially, I have included this <link>: <link rel="stylesheet" href="/css/dark.css" id="theme"> To sw ...

Using Jquery to target an element within the same DOM element and apply changes

My website platform doesn't assign any IDs or classes to the menus it generates, and uses nested lists for submenus. To make the submenus expand upon clicking, I created a jQuery script: $(function () { $(".wrapper ul li").click(function () { ...

Sizing grids with Susy framework

My goal is to construct a grid layout utilizing the Susy plugins, but I'm encountering an issue where there is extra space present within it. $susy: ( gutter-position: after, container: 1280px, container-position: center, columns: 14, gutter ...

Display a PHP warning message when attempting to add methods to ajax jQuery

Recently, I have delved into the world of ajax and jQuery while working on my final year project. However, I have encountered a problem when adding methods to my JavaScript code. Here is an excerpt from my ajax script: $(document).ready(function() { $ ...