Swap out the default white/blank box in Bootstrap

Hello, I am new to using bootstrap and trying to enhance my skills. Currently, I have created 5 boxes - two on the left side and three on the right side. However, I have a few questions regarding their display. Firstly, I notice that box number '5' appears differently compared to numbers 2 and 4. It seems like it has some margin-left, although in reality it does not. My second question pertains to aligning the boxes to the center when using 'col-xs-12'. Is there a way to achieve this easily? Moving on, my third question involves the responsiveness of the layout. When I switch my phone to 'landscape' mode, I want the boxes to retain their positions exactly as they are now on larger screen sizes (col-lg-6 col-md-6 col-sm-6). Lastly, I have an extra box labeled 'white space' which I would like to hide without affecting the overall functionality of the layout. Is it possible to replace that with 'Display: none;' or 'visibility: hidden;'? I apologize for any language barrier, English is not my native tongue.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8>;
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

  <style>
  .box{
  width:100px;
  height:100px;
  border: solid black 1px;
  }
   .boxx{
  width:100px;
  height:100px;
  border: solid white 1px;
  }
  * {
    box-sizing: border-box;
    box-sizing: border-box;
    -webkit-box-sizing -moz-box-sizing: border-box;
}
    </style>
</head>

<body>
<div class="row">
    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
        <div class="boxx">
            white space 
        </div>
    </div>
    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
        <div class="box">
            2
        </div>
    </div>
     <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
        <div class="box">
            3
        </div>
    </div>
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
        <div class="box">
            4
        </div>
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
        <div class="box">
            5
        </div>
    </div>
    </div>
    </div>
</div>


   
</body>
</html>

Answer №1

There seems to be some issues with the DIV structure. Please refer to the updated code below for resolution. We hope this helps.

.box{
  width:100px;
  height:100px;
  border: solid black 1px;
  }
   .boxx{
  width:100px;
  height:100px;
  border: solid white 1px;
  }
  * {
    box-sizing: border-box;
    box-sizing: border-box;
    -webkit-box-sizing -moz-box-sizing: border-box;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>

<body>
<div class="row>
    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">   
        <div class="boxx"> 
            white space 
        </div>  
    </div>
    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">   
        <div class="box"> 
            2
        </div>  
    </div>       
     <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">   
        <div class="box"> 
            3
        </div>  
    </div> 
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">   
      <div class="box"> 
          4
      </div>  
    </div> 
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">   
      <div class="box"> 
          5
      </div>  
    </div>     
    </div>
</div>


   
</body>
</html>

Answer №2

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

  <style>
  .box{
  width:100px;
  height:100px;
  border: solid black 1px;
  margin-left: auto;
  margin-right: auto;
  }
   .boxx{
  width:100px;
  height:100px;
  border: solid white 1px;
  margin-left: auto;
  margin-right: auto;
  }
  * {
    box-sizing: border-box;
    box-sizing: border-box;
    -webkit-box-sizing -moz-box-sizing: border-box;
}
    </style>
</head>

<body>
<div class="row">
    <div class="col-sm-6">
        <div class="boxx">
            white space 
        </div>
    </div>
    <div class="col-sm-6">
        <div class="box">
            2
        </div>
    </div>
     <div class="col-sm-6">
        <div class="box">
            3
        </div>
    </div>
  <div class="col-sm-6">
        <div class="box">
            4
        </div>
    </div>
    <div class="col-sm-6 col-sm-offset-6">
      <div class="box">
          5
      </div>
    </div>
</div>
   
</body>
</html>

Hey there! Are you encountering issues with the div structure and grid layout? I've made some adjustments to address these problems. Let me know if this is what you were looking for or if you need more assistance.

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

What's the issue with my jQuery AJAX script?

I am experiencing an issue with my ajax pages using jQuery to retrieve content. Only one page seems to be working properly, even though I have multiple pages set up. How can I resolve this problem? $(document).ready(function() { $('.lazy_content& ...

What could be the reason for Selenium refusing to accept dynamic variables in this specific function?

What is the reason for the difference in behavior between these two code snippets? monday_div = driver.find_element(By.XPATH, '//*[@id="GXPMonday"]') And why does this one not work as expected? weekdays = ['Monday', 'Tue ...

Encountered a problem while attempting to create two separate div elements. The template root is designed to have only one element. This issue

<template> <div class="footerpart-container"> <div class="general-container"> dadada </div> <div class="legal-container"> dadad </div> <div class="helpsupport-container"> dada ...

Is it possible to add a jQuery-generated element to pure vanilla JavaScript?

I am facing a challenge in creating a new notification div when an event is triggered. Ideally, I would normally achieve this using jQuery by utilizing something like $("myDiv").append(newDiv). However, in this case, the item selector to which the new div ...

Creating a multi-level mobile navigation menu in WordPress can greatly enhance user experience and make

Hey there, I am currently in the process of developing a custom WordPress theme and working on creating a mobile navigation system. Although I have managed to come up with a solution that I am quite pleased with after multiple attempts, I have encountered ...

Exploring methods for testing an HTML page that utilizes jQuery for DOM manipulations

Recently, I was tasked with creating an HTML page that utilized jQuery DOM manipulations. For instance, upon clicking the submit button, a success or error message should be displayed. Testing these functionalities is something I'm familiar with in An ...

Looking to implement URL navigation based on a selected value from a dropdown menu when the onClick button is pressed

I am struggling with getting the Go Button to navigate to a specific URL like "&age=10" without selecting it. I require assistance with creating code that will allow me to redirect to the URL with post URL variables for my WordPress site. ...

Issues with passing form data from an HTML label control to the controller are causing challenges

This particular type of HTML form control does not transmit form data. <form action="index.php?action=createNewCustomer" method="POST"> <fieldset> <label class="field" for="firstName">First Name:</label> <input type="text ...

Displaying a div when hovering over it, and keeping it visible until clicked

I want to display a div when hovering over a button. The shown div should be clickable and persistent even if I move the cursor from the button into the shown div. However, it should be hidden when moving out of the entire area. I'm unsure about how ...

CSS Color-Range Conditional Styling

I am interested in creating a simple chart using divs and spans, with the goal of implementing conditional formatting on each column based on its value to determine height. I have been struggling with figuring out how to make it work similar to Excel' ...

When clicking on a checkbox's assigned label, Chrome and IE may experience delays in firing the change event

When a user checks a checkbox under a specific condition, I want to display an alert message and then uncheck the checkbox. To achieve this, I am utilizing the click function on the checkbox to internally uncheck it and trigger necessary events. I have a ...

How can you use jQuery to transform a H3 tag into a clickable link?

To transform the h3 tag into a clickable link with jQuery and set the href attribute, while preserving the H3 styling and adding an anchor tag, you can use the following code as an example: Click Here ...

Error: The object does not have a method called 'to top scroller' and it is causing an uncaught type error

A plugin was obtained from the following link: http://www.jqueryscript.net/other/jQuery-Plugin-For-Smooth-Scroll-To-Top-Bottom-scrollToTop.html.i and the code was attached below in the index.html file. Several jQuery plugins were attempted, but none work ...

Confirming user credentials for every page

I am currently working with an HTML page that includes front end PHP for server side scripting. One issue I have encountered is the configuration page, which can be accessed by disabling JavaScript in Mozilla settings. My current validation method relies ...

Craft a circular design with an Arc and a Pie using the DIV DOM element

After creating an ellipse using the div DOM element, here's how I did it: var body = document.querySelector('body'); var div = document.createElement('div'); div.style.borderRadius = '50%'; div.style.border = '1px s ...

What could be causing the shadowbox not to display in Internet Explorer?

I am currently working on fixing a shadowbox issue in Internet Explorer. The page where the shadowbox is located can be found at this link: Here is the HTML code: <div class="hero-image"> <a href="m/abc-gardening-australia-caroli ...

Implementing a countdown timer using a database column value

Is there a unique way to utilize user-entered values in a database as a dynamic timer countdown that persists even after page refresh? I'm encountering an issue where the displayed value remains static. Are there alternative methods for implementatio ...

Validating Variables

One challenge I'm facing is creating a validation variable to validate the same input with different maximum numeric values. For instance, if I set a validation variable with a max numeric value of either 400 or 1000, entering 500 works fine for the f ...

What is the process for adding JSON object data to an existing JSON file using an HTML input form?

I have a JSON file named "WordMeanings.json" on my computer with the following data: { "WordMeanings": [ { "bangla": "ei je", "example": "Hi there!", "english" ...

The overflow property is not functioning as anticipated

I've browsed Google and this site, but I couldn't find a solution to my issue. On my webpage, I have a shoutbox and a teamspeak viewer with a specific height for the outer div. The scrollbars don't look good on our new design, so I attempt ...