What is the best way to split an image in half without displaying it and avoiding any horizontal scrolling on the page?

https://i.sstatic.net/Kj99o.png https://i.sstatic.net/W1BQ8.png

Trying to align the two images shown above, but facing issues with making it responsive. The SVG image exceeds the container boundaries, causing horizontal scrolling. The goal is to have the image "cut in half", eliminate horizontal scroll, and remove any white space on the right side. Looking for suggestions on how to achieve this.

import React from "react";
import illustrationWorking from "../images/illustration-working.svg"

const Hero = () => {
    return (

        <section className={'hero'}>
            <div className={'container'}>
                <h1>More than just shorter links</h1>
                <div className="row">
                    <div className="col">
                        <p>Build your brand’s recognition and get detailed insights on how your links are performing.</p>
                        <button variant="info">Get Started</button>{' '}
                    </div>
                    <div className="col">
                        <img
                            className="illustration"
                            loading={'lazy'}
                            src={illustrationWorking}
                            alt={'Illustration Working'}
                        />
                    </div>
                </div>


            </div>
        </section>


    )

}
export default Hero;

Answer №1

Here's an example of using clip property:

<style>
img 
{
    position:absolute;
    clip:rect(0px,60px,200px,0px);
}
img:hover{
    clip:rect(0px,100px,200px,0px);
} 
</style>

<img src="http://www.w3schools.com/cssref/w3css.gif" width="100" height="140" />

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

Position the div to align with just one side of the table-cell

I am struggling with making the height of my code dependent on only the left column, while still allowing the right column to be scrollable if it contains more content than the left column. Despite my best efforts, I can't seem to figure out how to a ...

How can I maintain form data submission to the server without triggering a redirect?

I am currently in the process of developing a web application that utilizes the Spotify API. My goal is to utilize the user input data to trigger calls to the Spotify API on the server and then relay the results back to the front end. However, I have encou ...

Utilizing React Native for seamless deep linking with automatic fallback to a webpage, including the ability to pass

I am currently working on a project that involves a website built with React and a React-native app for camera functionality and data processing. On the website, there is a button that opens the camera in the React-native app through deep-linking. This pa ...

Using Page.ResolveClientUrl in JavaScript or jQuery allows for easy resolution of client

I find myself in a predicament where I need to choose between using an HTML page instead of a .aspx page for performance reasons. Currently, I am using an aspx page solely because of the CSS and javascript file paths like: <script type="text/javascript ...

Is it possible to run a query directly from HTML code?

I am trying to retrieve data from my table that includes two columns: Judul, Isi. <head><link type="text/css" rel="stylesheet" href="addnewpage.css"/</head> <body> <?php $k = mysqli_connect("local ...

Updating Button Text with PHP on WooCommerce

Hi there, I'm trying to find a way to translate a button in my WooCommerce store without using LocoTranslate or any other tools. Is there a PHP function that can help me change the button text without needing an ID? If you want to take a look at the ...

What are some ways to resolve this console error: "TS2307: Could not locate module '@components/common/ButtonBlock' or its corresponding type declarations."

While the project is running smoothly, I am noticing a multitude of errors appearing in the console of VS Code. How can I eliminate these error messages? It seems to be related to TypeScript. Additionally, I am encountering an error in the browser as well ...

What is the best way to update auto margins after resizing an element with Javascript?

I'm having an issue with a DIV on my webpage that is centered using margin-left and margin-right set to auto. When I try to resize the DIV, it no longer stays centered on the screen. <div id="content" style="margin-left:auto;margin-right:auto;widt ...

What is the best method for adjusting the initial cursor position in a text field component of Material UI (Version 5.14.6)?

Is there a way to adjust the starting position of the cursor in a text field component using Material UI? In our project, we are working with the latest version of Material UI and utilizing the TextField component. However, we have noticed that the cursor& ...

Is there a way to adjust the placement of the h1 tag using the before pseudo-element?

I'm looking to place an image on the left side of each h1 tag. I've been attempting to utilize the before pseudo element for this task. The issue arises when there is no content, causing the before pseudo element to overlap with the h1 tag. How ...

Is it possible to use WHILE loops twice in PHP?

Just starting out with PHP and hoping for some assistance. I have a MySQL database table with columns for "id", "img", "link", and "desc". My goal is to echo all of this data in the following format: <div id="featured"> <a target='_b ...

The JavaScript function modifies the value stored in the local storage

I'm in the process of developing a website that requires updating the value of my local storage when certain JavaScript functions are executed. Currently, I have this code snippet: localStorage.setItem('colorvar', '#EBDBC2'); I&ap ...

Differences between .php and .html: What causes variations in IE rendering?

After duplicating one of the HTML pages in my project, I simply changed the file extension from .html to .php. Surprisingly, all browsers display the page identically except for Internet Explorer (IE), which seems to handle the pages differently based on t ...

Encountering an issue with React Redux and Typescript involving the AnyAction error while working on implementing

While integrating redux-persist into my React project, I encountered an error. Previously, Redux was working smoothly, but upon the addition of redux-persist, I started receiving this error message: Types of property 'dispatch' are incompatib ...

Encountering a problem with Alias in webpack while trying to render client-side React components

When using an Alias defined in webpack for client-side React rendering, I encountered an issue when attempting to render on a Node server using Express. In my webpack configuration, I have set up some aliases as shown below: resolve: { extensions: [& ...

There seems to be a bug in the reducer within the store (using react, redux toolkit, and TypeScript)

Utilizing redux with typescript, I aim to create a reducer that will modify the state of the store, and my defined types are as follows: interface IArticle { id: number, title: string, body: string, } type ArticleState = { articles: IArticle[] } ...

swap out the CSS class for my own class dynamically

When I display HTML code like this <div class="btn btn-pagination"> <i class="fa fa-angle-right"></i> </div> and want to replace fa fa-angle-right with myClass when the page loads. I attempted: $(document).ready(function () { ...

Incorporating specific item into a table using PHP

On my page, I have 3 select forms and an addToCart button. The select forms are populated with data from the database to display products without any issue. However, when a user clicks on the addToCart button, I need to capture the selected values from t ...

Ways to modify the appearance of the Sign up page on Moodle

I'm a newcomer to the world of Moodle, currently using version 2.9. I've created a unique design for my Signup page using HTML5 and CSS. How do I go about integrating this custom page? While I understand how to change the default Login page by m ...

Unable to properly cancel a post request using abort functionality

In the process of building a Next.js app, I encountered an issue with calling a post request. I included a cancel button to halt the post request, and attempted to use abortController in conjunction with Axios (v1.4.0) to achieve this. Even though the &ap ...