Struggling with aligning an entire class to the right and adding padding within a class in React.js utilizing Bootstrap. Any tips or guidance would be greatly appreciated!

I am new to react js and bootstrap and need some help. I want to make a change where the Image on the right (as seen below) is placed all the way to the right on my website. Currently, the text and image are too close together. How can I achieve this? Below you will find the code for that webpage as well. https://i.sstatic.net/6OoTa.png

import React from "react";
import web from "../src/images/myimage.svg";
import {NavLink} from "react-router-dom";

const Common =(props)  => {
    return (
         <>
          <section id = "header" className = "d-flex align-items-between  ">
          <div className = "container-fluid">
            <div className = 'row'>
                <div className = "col-10" mx-auto>
                  <div className ="row">  

                  
                  <div className = "col-md-6 pt-5 pt-lg-0 order-2 order-lg-1 d-flex justify-content-center flex-column">
                    <h1>{props.name} <strong className = "brand-name"> Pinnacle Tutorials</strong>
                    </h1>
                    <h2 className = "my-3">
                       We are a team of talented Teachers here for your ward
                     </h2>
                     <div ClassName = "mt-3">
                         <NavLink to={props.visit} className = "btn btn-success">Get Started check - {props.btname}</NavLink>
                     </div>

                  </div>
                  <div className = "col-lg-6   order-6 order-lg-5  header-img  d-flex justify-content-end">
                    <img src ={props.imgsrc} className = "img animated" alt = "home img "/>

                  </div>
                  </div>
                </div>
               </div>
              </div>  
          </section>
         </>

     
    );
};

export default Common;



NAVBAR CODE :

import React from "react";
import { NavLink } from "react-router-dom";

const Navbar = () => {
    return (
        <>
         <div className = "container-fullwidth nav_bg">
            <div className = 'row'>
                <div className = "col-12 mx-auto">

           
          <nav className="navbar navbar-expand-lg navbar-light bg-light py-3 container-fluid">
  <NavLink className="navbar-brand" to="/">Pinnacle Tutorials</NavLink>

  <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span className="navbar-toggler-icon"></span>
  </button>

  <div className="collapse navbar-collapse" id="navbarSupportedContent">
    <ul className="navbar-nav ms-auto">
      <li className="nav-item active">
        <NavLink activeClassName ="menu_active" exact className="nav-link" to="/">Home <span className="sr-only">(current)</span></NavLink>
      </li>
      <li className="nav-item">
        <NavLink activeClassName ="menu_active" className="nav-link" to="/about">About</NavLink> 
      </li>
      <li className="nav-item">
        <NavLink activeClassName ="menu_active" className="nav-link" to="/service">Services</NavLink>
      </li>
      <li className="nav-item">
        <NavLink activeClassName ="menu_active" className="nav-link" to="/contact">Contact</NavLink>
      </li>
      
    </ul>
   
  </div>
</nav>
     </div>
            </div>

         </div>
        </>
    );
};
export default Navbar

Answer №1

The scenario at play here involves the creation of two columns, each with an equal width. To ensure that the column containing the image positions the image at the far end, I recommend implementing a flex-based solution. This involves setting the col element containing the <img> to display as flex, which can be achieved by applying the class d-flex, followed by adding justify-content: flex-end; to it using the class name justify-content-end.

Ultimately, your div structure should resemble the following:

<div className = "col-lg-6 order-6 order-lg-5 pad-10 header-img d-flex justify-content-end">
   <img src ={props.imgsrc} className = "img-fluid animated" alt = "home img "/>
</div>

Answer №2

p {
  padding-right: 150px;
}

<div class="bg-light d-flex justify-content-between">
    <div>Total Cost</div>
    <div>$50</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

Creating a React element clone

Within my library (antUI), I am able to pass a component inside a configuration like this: const configuration = [{ render: record => <Component record={record} /> }] I am trying to update that configuration by using the .map function: const ...

Creating custom template tags in Django

Why isn't my custom template tag working as expected? templatetags.py: from django import template from ..models import User register = template.Library() @register.inclusion_tag('main/post_detail.html', takes_context=Tru ...

Sending users to a different page in case the linked document from <a> cannot be located

I am in search of a way to set up an alternative link for a hyperlink in case the primary link does not exist, similar to how 'alt' works for images. I am aware of the existence of 'onerror' but it doesn't work for HTML links. I wo ...

Tips on invoking a function from an array in JavaScript when a button is clicked

Being new to JavaScript, I encountered a challenge where I have an array of functions: allFunctions = () => [ function1(), function2(), function3(), function4(), function5(), function6(), function7(), function8(), function9() ] My go ...

What is the best way to continuously loop the animation in my SVG scene?

After designing a SVG landscape with an animation triggered by clicking the sun, I encountered an issue where the animation only works once. Subsequent clicks do not result in any animation. Below is my current JavaScript code: const sun = document.getEle ...

Is it possible to use reactjs and react-router to showcase either a component or {this.props.children}?

Here's the scene: I have multiple components where certain words can be clicked to link to a reference page/component. If the highlighted words are not clicked, the component is displayed as is (and there are many of them with this feature and a menu ...

React js State not being Updated with New Values in the State Object

I'm currently learning React and hooks, and I'm facing an issue with setting the disabled state in the code snippet below. I want to disable the input field if the state.items.length is greater than 3, but I'm not seeing the updated values i ...

Error message: Unable to locate the ID attribute of this element using jQuery - resulting in undefined value

Trying to extract the ID and display it with an alert message upon clicking, but it keeps showing "undefined" instead. Can anyone provide some assistance? Here is the important part of the code: HTML: <img src="/pictures/picture.jpg" class="r-gal-photo ...

Managing the state in NextJS applications

I've scoured the depths of the internet in search of a solution for this issue, but unfortunately I have yet to come across one that effectively resolves it. I've experimented with various state management tools including: useContext Redux Zusta ...

Using Vue3 to conditionally display a child div based on the class of its parent div

Just starting out with Vue, I'm currently experimenting with the active classes feature from this Vue3 carousel plugin. My goal is to only show the text and link divs for the carousel__slide--active class, but at the moment, all carousel__items are di ...

Semi-fixed positioning with flex layout

I am encountering an issue with angular's flex-layout. I have implemented two divs with fxFlex, each containing a mat-card. My goal is to keep the right mat-card vertically fixed while maintaining responsive behavior when resizing the window. Does any ...

Does ColdFusion go through a compilation process?

I recently received a request from a client who is interested in adding a third-party lead generation popup script to a couple of her websites. One of these sites was built using ColdFusion, a language I have not had much experience with before. My questio ...

Error: The import statement is not valid outside of a module - code playground

While working on creating a JSFIDDLE to troubleshoot a problem with REACT/HIGHCHARTS, I encountered the following error - SyntaxError: Cannot use import statement outside a module You can check out my jsfiddle here - https://jsfiddle.net/5fcguapx/ I ...

Best practices for efficiently updating state in React components

Currently, I am in the process of learning React and trying to grasp its concepts by practicing. One exercise I decided to tackle involves deleting an element from an array when a user clicks on it in the UI. Below is the code snippet that I have been work ...

Navigating with React Router using URL parameters

After implementing react router with a route path taskSupport/:advertiserId that includes parameters, I encountered an issue when trying to access the link http://localhost:8080/taskSupport/advertiserId. My browser kept returning 404 (Not found) errors for ...

Display the scrollbar within a flexitem by utilizing flexbox styling

I am currently setting up my HTML website with Bootstrap flex and I have a specific layout in mind. I want the inner div to have scrollbars while the outer div fills up the rest of the page. Take a look at this example: <div class="d-flex align-items- ...

Tips for maintaining knowledge after redirecting to a new page

Building an app using Ionic 4 where I need to display vouchers from a database as images. Each image should act as a link to a details page showing more information about that specific voucher. However, I am struggling to figure out how to keep track of th ...

Leveraging JavaScript for Triggering an Infinite Loop of 1 GET and 2 POST Requests

I don't have much experience with JavaScript, but I believe this can be achieved. I require the script to perform 3 tasks: Make a GET request to https://example.com/test.php which will return this JSON: [{"user_id":"12345","email":"<a href="/ ...

Accessing and displaying all states in $stateProvider using AngularJS and ui-router

Here's a simple question: how can I find all instances of $stateProvider.state in my app.js, which is my AngularJS config file? In the past with ngRoute, I could achieve this by using a similar approach in my .run() block: .run(function ($route) { ...

What is the process for attaching an iterator to the name value of every element within a cloneNode?

Consider the following scenario: <div id="addNewMenuElementPart2"> Numerous elements with a name attribute are present here. </div> <div id="addNewMenuElementPart3Optional"></div> Additionally, t ...