the components progress down the line

For my right column implementation, I decided to use CSS position:relative and put different elements inside in position:absolute as shown below:

<!-- Right Column -->
<div class="col-xs-3 pl18"  style="position:relative;">

    <!-- Without insurance -->
    <div class="row pt23 p-absolute t141"  >        
        #parse('/right-col/sans-assurance.html.vtl')
    </div><!-- end row alc mb30 -->

    ...

</div><!-- end col-xs-3 -->
<!-- Right Column   -->

However, whenever I add a new element at the top of my right column, all the subsequent elements shift downwards. I have tried using jQuery without success. Can someone please suggest some ideas for fixing this issue?

Thank you.


I ran a test with the following code:

<body>
    <div>Hello</div>

    <div class="row" style="position: relative;">

        <div class="col-xs-3" style="position: absolute;top:10px;" >
                    Ola
                    <img src="fig-a01a.jpg" style="height: 100px;width: 100px;">
        </div>

        <div class="col-xs-3" style="position: absolute;top:200px;">
                    querida
                    <img src="Arthur.jpg" style="height: 100px;width: 100px;">
        </div>

         <div class="col-xs-1" style="position: absolute;top:400px;">
                    sin tchao
                    <img src="c.jpg" style="height: 100px;width: 100px;">
        </div>


        <div class="col-xs-1" style="position: absolute;top: 20px;">
                    anh phuong
        </div>


        <div class="col-xs-1" style="position: absolute;">
                    princessa
        </div>

     </div>
  </body>

Interestingly, no gap is created between the components with this test code. In contrast, there seems to be a gap when using my initial block of code. I am unsure why this is the case. Any suggestions on how to resolve this discrepancy would be greatly appreciated...

Answer №1

Oh wow, I have come across a useful solution that involves using JQUERY :

 $("#id_of_the_component_HTML").css({left:X,top:Y});

If you need to check if a component exists on a webpage :

if($('#id_of_the_component_HTML').length>0){

Therefore, include the following scripts in your HTML file:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

<script type="text/javascript">

            $(document).ready(function(){

                if($('#bea').length>0){

                    $("#position").css({left:0,top:-60});

                }

            });

 </script>                           

Incorporate the following elements into your HTML layout:

<div class=" col-xs-3 " id="bea" style="position: absolute;top:10px;" >
                    tao
                    <img src="bea.jpg" style="">
        </div>


        <div class="col-xs-3" id="position" style="position: absolute;top:10px;" >
                    Ola
                    <img src="fig-p01a.jpg" style="height: 100px;width: 100px;">
        </div>

This setup will allow you to move the object with ID position when placing the object with ID bea.

Cheers.

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 is the best way to store all rows in a dynamically changing table with AngularJS?

I am facing an issue while trying to dynamically add rows for a variable that is a String array in my database. The problem is that it only saves the last value entered in the row instead of saving all of them in an array. Here is my current view code: &l ...

How to pass variables in AngularJS

When displaying data in a grid, I need to change the button icon on click of the active or inactive button. The functionality is working well, but I am having trouble finding the clicked active button to change its icon. In jQuery, we can use "this", but ...

Is there a way to automatically close a created div by clicking anywhere outside of it?

I'm facing an issue with a dynamically created div that I want to close by clicking outside of it. However, when I try to achieve this functionality, the div closes immediately as soon as it is opened. closediv(); } function closediv() { d ...

Tips for incorporating inline images with gatsby-image

Seeking Solution In my quest to query and showcase images with a maximum width of 350px, I am hoping to have them displayed inline-block for tablets and larger screens. Ideally, each image would sit next to one another and wrap if they exceed the parent d ...

show: alongside move: towards the left

Reviewing some vintage CSS code from 2008, I stumbled upon the following CSS snippet for a menu/navigation: #menu li { display: inline; } #menu a { display: block; float: left; height: 32px; margin: 0; padding: 18px 30px 0 30px; ...

When attempting to click on the dropdown in Bootstrap, there is no content displayed

I am currently practicing Bootstrap and focusing on implementing Dropdowns. However, I am facing an issue where upon clicking the Dropdown button, nothing appears on the screen. Preview when it's not clicked Preview when it's clicked Here is m ...

Revolutionize your website with dynamic jQuery scripts

I am currently in the process of moving data from 'table_source' to 'table_dest'. The challenge I am facing is that 'table_source' is created using a repeater, which dynamically generates table IDs. However, I require the elem ...

Requirements for validating email with jQuery

Currently, I am using the jQuery.Validation plugin to handle client-side validation in my project. One key aspect of validation is checking email addresses. However, I have come to realize the importance of also validating on the server side for users who ...

Choosing the div elements that have a PNG background image assigned to them

Is there a way to use jQuery to target all the div elements with a background-image property set to url(somepath/somename.png) in their style? ...

Error Encountered: Angular JS Throwing Unhandled Injection Error

I am having trouble validating the fields in my index.html and js files. I keep seeing errors, even after trying different versions of angular-route.min.js and angular.js. AngularJs | Basic Login Form <body ng-app="myApp"> ...

Displaying a variety of images in an HTML document can be achieved without the need to manually write out a separate tag

As a newcomer to HTML, I find myself faced with a challenge. I have a folder containing 100 images, all sharing a common prefix in their names but differing in the second part. For instance, some examples include: "content_diffusion_delay_AthfT@jurEYTgf" a ...

Issues with slideToggle function causing the element not to expand as

I'm trying to use slideToggle() for expanding elements within a panel, but when I click, the function isn't working as expected. Below is the code snippet: HTML <div class="panel panel-default"> <div class="panel-heading"> ...

Creating a variety of Flexslider slideshows on the fly

Check out this snippet of code: <?php foreach ($objVideos as $objVideo) : ?> jQuery('#carousel-<?php echo $objVideo->id; ?>').flexslider({ animation: "slide", controlNav: false, animationLoop: false, ...

Is it possible to preserve the <canvas> elements to use for future animation frames?

Currently, I am working on a graph visualization project that involves complex calculations being done on an HTML5 canvas. My goal is to create an interactive animation where the graph remains fixed, but additional elements are overlaid as the mouse moves ...

best practices for choosing items from a dropdown menu using Angular

I have a dropdown list displaying existing tags/chips created by users in the past. However, I'm having an issue where when I select a tag from the dropdown list, it doesn't show up in my input field (similar to the Chart tag currently). I am abl ...

Could not connect: AJAX Request denied?

I am currently hosting a Digital Ocean server that runs on a MEN stack composed of MongoDB, Express, and Node. The registration form can be accessed at: When attempting to choose an option from the dropdown menu, I encounter the following error message: G ...

Floating CSS drop menu with added bottom margin

I have created a simple dropdown CSS menu positioned in the footer with an upwards direction. You can view it here: http://jsfiddle.net/RmTpc/11/ My issue is that I want the opened menu to have some bottom margin from the main list item ("Items"). However ...

What is the best way to populate an HTML array using my AWK script?

In my CGI script written in bash and HTML, I am attempting to display information from multiple CSV files in an HTML array. The following is the script I am using: #!/bin/bash echo "Content-type: text/html" echo "" echo ' <html> <he ...

Unable to modify text color after implementing mat-sort-header in Angular Datatable

My current setup involves using an Angular data table to display data. I recently added the mat-sort-header functionality, which allowed me to change the font color of the header text. Below is a breakdown of my code: <section id="main-content" ...

Angular's Spanning Powers

How can I make a button call different methods when "Select" or "Change" is clicked? <button type="button" class="btn btn-default" *ngIf="!edit" class="btn btn-default"> <span *ngIf="isNullOrUndefined(class?.classForeignId)">Select</spa ...