Having difficulty in setting items to a relative position in order to align them properly

I am struggling to align two div items next to each other using Bootstrap. This is for a product detail view where I want the image on the left and text on the right. It's a product detail page for an ecommerce site that I'm trying to create. Maybe this is not the best practice because I am not good at frontend development. Any help would be greatly appreciated.

Here is the code snippet I am working with:

    $(document).ready(function(){
    
        $(".tb").hover(function(){
        
        $(".tb").removeClass("tb-active");
        $(this).addClass("tb-active");
        
        current_fs = $(".active");
        
        next_fs = $(this).attr('id');
        next_fs = "#" + next_fs + "1";
        
        $("fieldset").removeClass("active");
        $(next_fs).addClass("active");
        
        current_fs.animate({}, {
        step: function() {
        current_fs.css({
        'display': 'none',
        'position': 'relative'
        });
        next_fs.css({
        'display': 'block'
        });
        }
        });
        });
        
        });
    .col-10{
           margin-left: auto;
           margin-right: auto;
       }
       .card {
        display: inline-block;
        position: relative;
        }
    
        fieldset.active {
            display: inline-block !important
        }
    
        fieldset {
            display: none
        }
    
        .pic0 {
            width: 400px;
            height: 500px;
            margin-left: 85px;
            margin-right: auto;
            display: inline-block;
        }
    
        .product-pic {
            padding-left: auto;
            padding-right: auto;
            width: 100%
        }
    
        .thumbnails {
            position: absolute
        }
    
        .fit-image {
            width: 100%;
            object-fit: cover
        }
    
        .tb {
            width: 62px;
            height: 62px;
            border: 1px solid grey;
            margin: 2px;
            opacity: 0.4;
            cursor: pointer
        }
    
        .tb-active {
            opacity: 1
        }
    
        .thumbnail-img {
            width: 60px;
            height: 60px
        }
    
        @media screen and (max-width: 768px) {
            .pic0 {
                width: 250px;
                height: 350px
            }
        }
        .detail_view{
            margin-right: 100px;
        }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container-fluid px-sm-1 py-5 mx-auto col-10">
            <div class="row">
                <div class="d-flex">
                    <div class="card col-12">
                        <div class="d-flex flex-column thumbnails">
                            <div id="f1" class="tb tb-active"> <img class="thumbnail-img fit-image" src="{{ item.first.url }}"> </div>
                            <div id="f2" class="tb"> <img class="thumbnail-img fit-image" src="{{ item.second.url }}"> </div>
                            <div id="f3" class="tb"> <img class="thumbnail-img fit-image" src="{{ item.third.url }}"> </div>
                            <div id="f4" class="tb"> <img class="thumbnail-img fit-image" src="{{ item.fourth.url }}"> </div>
                          </div>
                        <fieldset id="f11" class="active">
                            <div class="product-pic"> <img class="pic0" src="{{ item.first.url }}"> </div>
                        </fieldset>
                        <fieldset id="f21" class="">
                            <div class="product-pic"> <img class="pic0" src="{{ item.second.url }}"> </div>
                        </fieldset>
                        <fieldset id="f31" class="">
                            <div class="product-pic"> <img class="pic0" src="{{ item.third.url }}"> </div>
                        </fieldset>
                        <fieldset id="f41" class="">
                            <div class="product-pic"> <img class="pic0" src="{{ item.fourth.url }}"> </div>
                        </fieldset>
                        <div class="deatil_view" style="float: right;">
                          <p style="color: blue;">{{ item.categories.name}} / <span>{{ item.subcategories.name }}</span></p>
                          <h2>{{ item.name }}</h2>
                          <p>{{ item.brand_name }}</p>
                          <div class="price">{{item.offered_price|currency}} <span class="actual">  {{item.actual_price|currency}} </span> </div>
                          <strong>About: <br>
                          <span> {{ item.about }}</span></strong>
                          <br> 
                          <strong>Return Policy: <span>{{ item.return_policy }}</span> <a style="border: 1px solid #025; padding:2px" href="#">?</a> </strong>
                          </div>
                    </div>
                </div>
            </div>
        </div>

Answer №1

To create this layout, simply insert two columns within a row :

<div class="container-fluid px-sm-1 py-5 mx-auto col-10">
    <div class="row">
        <div class="d-flex">
            <div class="card col-auto">
                <div class="d-flex flex-column thumbnails">
                    <div id="f1" class="tb tb-active"> <img class="thumbnail-img fit-image" src="{{ item.first.url }}"> </div>
                    <div id="f2" class="tb"> <img class="thumbnail-img fit-image" src="{{ item.second.url }}"> </div>
                    <div id="f3" class="tb"> <img class="thumbnail-img fit-image" src="{{ item.third.url }}"> </div>
                    <div id="f4" class="tb"> <img class="thumbnail-img fit-image" src="{{ item.fourth.url }}"> </div>
                  </div>
                <fieldset id="f11" class="active">
                    <div class="product-pic"> <img class="pic0" src="{{ item.first.url }}"> </div>
                </fieldset>
                <fieldset id="f21" class="">
                    <div class="product-pic"> <img class="pic0" src="{{ item.second.url }}"> </div>
                </fieldset>
                <fieldset id="f31" class="">
                    <div class="product-pic"> <img class="pic0" src="{{ item.third.url }}"> </div>
                </fieldset>
                <fieldset id="f41" class="">
                    <div class="product-pic"> <img class="pic0" src="{{ item.fourth.url }}"> </div>
                </fieldset>
            </div>
            <div class="col">
              <div class="deatil_view">
                  <p style="color: blue;">{{ item.categories.name}} / <span>{{ item.subcategories.name }}</span></p>
                  <h2>{{ item.name }}</h2>
                  <p>{{ item.brand_name }}</p>
                  <div class="price">{{item.offered_price|currency}} <span class="actual">  {{item.actual_price|currency}} </span> </div>
                  <strong>About: <br>
                  <span> {{ item.about }}</span></strong>
                  <br> 
                  <strong>Return Policy: <span>{{ item.return_policy }}</span> <a style="border: 1px solid #025; padding:2px" href="#">?</a> </strong>
                  </div>
            </div>
        </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

Tips on how to update the page and create a counter for a table view

I am working with an HTMLB Tableview where I need to regularly update its firstRowVisible property every 3 minutes with a dynamic value. For example, if it starts at zero, after 3 minutes it should be set to 21 and continue increasing by a certain interval ...

Guide on applying a filter to the items in a listbox using the input from a text box

In my HTML form, I have the following elements: 1) A list box containing filenames: s1.txt2013 s2.txt2013 s3.txt2012 s4.txt2012 2) A text box where the user enters a pattern (e.g. 2013) 3) A button By default, the list box contains the 4 file ...

Best practices for customizing v-calender in vue.js

I'm struggling with styling my calendar using the v-calendar Vue plugin. I want to customize the background of the calendar, but my code doesn't seem to be working. Can someone please help me out? Thank you in advance. HTML <v-calendar ...

What is the best method for fetching the values of a select element in React.js?

I'm struggling to retrieve the value of a selected element in a dropdown list. I've tried debugging it, but haven't been able to get the value. I attempted to console log e.target.value, but unfortunately, it didn't work. Any thoughts o ...

Uh-oh! Looks like there was an issue with the AJAX response: net::

CODE: FRONT-END $(document).ready(function(){ $('.delete-post').on('click', function(){ var id = $(this).data('id'); var section = $(this).data('section'); var url = &apo ...

"Bootstrap4 - Troubleshooting the Issue of Multiple Carousels Not Function

I attempted to incorporate 2 Bootstrap 4 carousels onto a single page, but encountered issues with the functionality. I utilized this code on my page, however, the last element in the carousel does not cycle correctly. There is a delay of 3 transactions be ...

I am having trouble getting the graph to display using PHP and MySQL on Fusion Charts

I am looking to create a line graph based on data from my database. This is my first time working with Fusion Charts, so I followed the instructions in their documentation for dynamic charts. Here is the code from my PHP page: <?php include("Includes/F ...

Ensure that all items retrieved from the mongoDB query have been fully processed before proceeding further

In the midst of a challenging project that involves processing numerous mongoDB queries to display data, I encountered an issue where not all data was showing immediately upon page load when dealing with large datasets. To temporarily resolve this, I imple ...

The app.get() method in Node JS and Express requires three parameters, and I am seeking clarification on how these parameters work

Hey there, I'm new to this and have a question regarding my code using passport-google-oauth20. app.get('/auth/google/secrets', passport.authenticate('google',{failureRedirect: '/login'}), function(req,res){ res.redirec ...

JavaScript function to close mobile menu when menu item is clicked

https://i.sstatic.net/GfKem.png I have a dilemma with my HTML code. I am trying to figure out how to collapse the menu when clicking on a menu item using JavaScript. I have been stuck on this for two days now. Can anyone provide a solution with an explanat ...

Angular CDKScrollable not triggering events

I'm having trouble making the angular CdkScrollable work when creating my own div: <div class="main-section" id="mainsection" #mainsection CdkScrollable> <div class="content" style="height: 300px; backgr ...

Troubleshooting a Non-Responsive React onClick Event in ES6

I am a beginner in React and have been searching on various platforms like StackOverflow and the internet, but I cannot figure out why onClick is not working in my case. When I click the button, absolutely nothing happens. I have tried everything from putt ...

Initiate an Ajax call to pre-fetch video content

I've been attempting to download a video from my own source and display a loading message while it's being downloaded. Once the download is complete, I want to hide the loading icon and have the video ready for playback. My issue lies in gettin ...

Switching icon with jQuery upon clicking

I'm just starting to learn jQuery and I'm working on changing the font icon class when clicked to display a drop down. Right now, it changes the icon and drops down the content as expected. However, I'm facing an issue where I want the icon ...

The custom error page in NextJS is failing to display

In my custom pages/404.ts file, I have coded the following: export default function NotFound() { return <h1>404 - Page Not Found</h1> } Additionally, there is another page that displays a 404 error when the organization is null: import Error ...

"Can you help me figure out how to transform a date string into a concise date object using JavaScript

As a newcomer to UI coding, I am faced with the challenge of working with date data from JSON in the format "2021-02-28 00:00:00". However, when writing to an xlsx file, I need the date to be in a different format rather than as a string. Here is my attemp ...

What distinguishes submitting a form from within the form versus outside of it?

When the code below, you will see that when you click btnInner, it will alert 'submit', but clicking btnOuter does not trigger an alert. However, if you then click btnInner again, it will alert twice. Now, if you refresh the page: If you first ...

Execute an HTTP POST request to the Node server, sending an empty object

For my project, I am attempting to send an HTTP Post request to my Node server from an html form. Despite using Body Parser and setting it up correctly, I am facing an issue where the req.body on my server is returning as an empty object. Can anyone prov ...

Hide the div element once the timer runs out

Struggling to make a timer disappear when it reaches 00:00, every attempt results in the div being hidden immediately. Check out the code snippet I've been working with: $(document).ready(function(e) { var $worked = $("#worked"); function upd ...

Conceal a column within a table by double-clicking

I'm working on a project with a table, and I'd like to implement a feature where a column hides when double-clicked. I've seen various solutions for hiding columns on Stack Overflow, but I could use some guidance on where to add the ondblcli ...