Are the Div Tags displaying in a vertical alignment instead of a horizontal one?

I have 3 div elements, each with a width of 4. I want to align them all in a row but I am also using a toggle button to show these divs because by default their display is set to none. When the user clicks the toggle button, the divs will be shown to them. The issue I am facing is that the divs are showing up vertically in three rows instead of horizontally in a single row.

<div class="col-lg-4">
  <div class="custom-control custom-switch" style="margin-left:25px">
   @Html.CheckBox("Select Raw Targets", new { @class = "custom-control-input", id = "rawTargetSelection" })
   <label class="custom-control-label" for="rawTargetSelection">Select Raw Targets</label>
                                    </div>
                                </div>
<!-- Raw Target Tags Values Tabs Starts Here -->
                            <div class="row" id="Real_Tag_Targets" style="display:none">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label>Select Real Tag Targets</label>
                                        @Html.DropDownList("Raw Tag Targets", (IEnumerable<SelectListItem>)ViewBag.rawTagTargetValue, new { @class = "form-control add_item", @multiple = true, id = "Raw_Tag_Target_List" })
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label>Select Real Tag Min Targets</label>
                                        @Html.DropDownList("Raw Tag Min Targets", (IEnumerable<SelectListItem>)ViewBag.rawTagTargetMin, new { @class = "form-control add_item", @multiple = true, id = "Raw_Tag_Min_Target_List" })
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label>Select Real Tag Max Targets</label>
                                        @Html.DropDownList("Raw Tag Max Targets", (IEnumerable<SelectListItem>)ViewBag.rawTagTargetMax, new { @class = "form-control add_item", @multiple = true, id = "Raw_Tag_Max_Target_List" })
                                    </div>
                                </div>
                            </div>

 $("#rawTargetSelection").change(function () {
             var x = document.getElementById("Real_Tag_Targets");
            if (x.style.display === "none") {
              x.style.display = "block";
            }
            else
            {
               x.style.display = "none";
            }
        });

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

Answer №1

It appears that you are starting a row after a column, but without the complete code, it is difficult to diagnose the issue accurately. It would be helpful to provide a better example code that isolates the problem. Additionally, consider removing the server code and focusing solely on the HTML output since this seems to be a markup-related problem.

One thing to note is that you are setting the display property of the row (which uses flex) to block, which could be causing some layout issues.

$("#rawTargetSelection").change(function() {
  var x = document.getElementById("Real_Tag_Targets");
  if (x.style.display === "none") {
    //x.style.display = "block";
    x.style.display = "flex";
  } else {
    x.style.display = "none";
  }
});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-lg-4">
  <div class="custom-control custom-switch" style="margin-left:25px">

    <label class="custom-control-label" for="rawTargetSelection">Select Raw Targets</label>
  </div>
</div>
<!-- Raw Target Tags Values Tabs Starts Here -->
<div class="row" id="Real_Tag_Targets">
  <div class="col-md-4">
    <div class="form-group">
      <label>Select Real Tag Targets</label> -input-
    </div>
  </div>
  <div class="col-md-4">
    <div class="form-group">
      <label>Select Real Tag Min Targets</label> -input-
    </div>
  </div>
  <div class="col-md-4">
    <div class="form-group">
      <label>Select Real Tag Min Targets</label> -input-
    </div>
  </div>
</div>

<!-- Raw Target Tags Values Tabs Starts Here -->
<div class="row" id="Real_Tag_Targets">
  <div class="col-4">
    <div class="form-group">
      <label>Select Real Tag Targets</label> -input-
    </div>
  </div>
  <div class="col-4">
    <div class="form-group">
      <label>Select Real Tag Min Targets</label> -input-
    </div>
  </div>
  <div class="col-4">
    <div class="form-group">
      <label>Select Real Tag Min Targets</label> -input-
    </div>
  </div>
</div>

<style>
  div, label {
    border: 1px dotted #f00;
  }
</style>

Answer №2

It appears that the issue lies within the @html checkbox style property. I recommend double-checking this as it seems to be the cause of the problem, as everything works fine without it.

Answer №3

Experiment with:

x.style.visibility = "visible";

within your code block

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

Bringing in States and Functions to a React Component

Is there a way to improve the organization of states and functions within a functional React Component? Here's my current code structure: import React from 'react' //more imports... const Dashboard = () => { const [] = useState() / ...

Turn off Chrome 69's autofill functionality

I've recently encountered an issue with Chrome's password autofill feature that has been troubling me for a few days now. This problem began when I was using Chrome version 69. After much trial and error, I found a solution by removing the id an ...

What is the best way to customize the appearance of these two images within a div element?

While working on a small website project during my internship, I initially used an inline stylesheet. However, upon my boss's recommendation, I switched to an external stylesheet. Now, I'm trying to figure out how to style the two images within d ...

Instructions for rearranging the configuration of a 2D array?

A 2-dimensional array is created from a string called matrix: 131 673 234 103 018 201 096 342 965 150 630 803 746 422 111 537 699 497 121 956 805 732 524 037 331 After parsing, it becomes an array of arrays like this: [ [131, 673, 234, 103, 018], [2 ...

Embed an HTML element within a DIV container

How can I add an HTML tag such as <p> to wrap around the text "Search"? <button id="ihf-quicksearch-submit2" class="btn btn-lg btn-block btn-primary btn-form-submit ihf-main-search-form-submit" type="submit"> Search </button> I am looki ...

Enhancing user experience by implementing dynamic text box functionality that triggers ajax load for dropdown options using a combination

Here is the task I need help with, along with the code snippet: I want to enable the author select box when both the start and end dates are filled out. The author names should be fetched dynamically from the database based on the selected start and end ...

"Sorry, but window.print function is not available in this environment

Whenever I try to execute something in jest, I keep encountering the same error message: console.error node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/virtual-console.js:29 Error: Not implemented: window.alert at module.expor ...

Ways to create a fading effect for a div container

As I delve into learning Rails, I've been immersed in a Rails web app where there is an enticing "Order" button that triggers a response saying: "Thank you for ordering". This message is displayed using the flash action. To enhance user experience, my ...

Tips for saving React console logs to a server

We are looking to understand the root cause of the issue occurring on the client side and figure out a way to store client console logs on the server side. How often should we send these logs to the server for storage? We also want to make sure that when ...

What could be the reason for an ASP.NET Core application not loading within an iframe on the same domain?

I am facing an issue with my ASP.NET Core MVC website, which is embedded as the src of an IFRAME within a portal. Both the portal and the .NETCore application share the same domain (e.g., site.portal.domain / portal.domain). Upon entering the portal, I en ...

What is the best way to display three unique maps simultaneously on separate views?

In this scenario, I have incorporated three separate divs and my goal is to integrate three maps into them. The javascript function that controls this process is as follows: function initialize() { var map_canvas1 = document.getElementById('map_canva ...

When I use the select picker class, the <select> tag does not appear as intended

Is there a way to retrieve data from the second select, specifically the one with the class 'select picker'? I am encountering an issue where the data is not displaying when using the bootstrap-select component. I have confirmed that the componen ...

Adding a static javascript file to a Vue CLI 3 project is a straightforward process

Currently working on a vue-cli-3 project and looking to include a static javascript file. Curious about the proper way to import this file. The typical method used is: <script src="js/myfile.js"></scrip> ...

The functionality of this.clusterer is not defined when trying to add a marker using this.clusterer.addMarker(marker);

I'm encountering an error message that says this.clusterer is undefined. Below is an overview of my configuration. Expected behavior: The page should load, then AJAX-load the markers from the controller using the query defined in #search_form. Finall ...

Is it possible to make an image gradually appear and disappear?

Is there a way to create a continuous fade in and out effect for an image, transitioning between 40% and 100% opacity? I attempted using a CSS3 opacity property, but it only allows for 0% and 100%, causing the fade effect to be ineffective. Does anyone h ...

Encountering an issue: Laravel 8 showing CSRF token mismatch error

I encountered an issue while attempting to submit a form in Laravel using AJAX, which includes various input fields and a file upload option. Upon submitting the form, I received the following error message: {message: "CSRF token mismatch.", ex ...

How can I verify the presence of links in an input field and determine its character count?

I've dived into coding for this project and I'm making progress. Here are my objectives: 1) Verify the length of URLs entered in a field and reduce each link's length by 20 if it exceeds 20 characters. 2) Calculate the remaining characters i ...

What is the best way to create synchronous AJAX requests?

Can I convert this into a function? // Function to check if station is alive function checkStation(valueSelected) { let result = false; $.ajax({ url: "lib/grab.php", data: "check_live=1&stream_url="+valueSelected, ...

Typescript indicates that an object may be 'undefined' when the value is an empty string

I'm new to Typescript and currently working on converting our application from React JSX to TS. If I'm misunderstanding the error, please let me know. I've encountered the error message Object is possibly 'undefined' related to a ...

What are some ways to incorporate texture into objects using three.js?

Having trouble adding texture to my central sphere (earth) without the object disappearing. Can someone provide guidance on where I might be making a mistake? Your help is appreciated. For reference, here is the link to my jsbin http://jsbin.com/cabape/edi ...