The components/elements are misaligned and causing interference with each other

Currently, I am in the process of constructing a homepage that requires the display of an image alongside text, paragraphs, buttons, and icons. Here is my goal:

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

However, this is what I have managed to accomplish so far:

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

A few days back, I had successfully implemented this design. However, due to the complexity of the layout and CSS involved, it led to a complete mess on my page. To avoid any further complications, I decided to start from scratch by adding text first, then replacing it with content, ensuring everything fits together seamlessly.

You can see that the placement of text, titles, icons, and buttons is all disjointed from the image. It seems like using a div with the image as a background might be necessary.

In the past, I've experienced situations where the positioning of elements such as text and buttons on top of images would shift unpredictably, potentially influenced by other elements.

Below is the code snippet:



import React from 'react';

import VillageBanner from '../assets/images/village-banner-icon.png';
import DiscoverImage from '../assets/images/discover-home.jpg';
import WhiteButton from '../components/materialdesign/WhiteButton';
import BlueButton from '../components/materialdesign/BlueButton';
import HomeCarousel from '../components/HomeCarousel';
import Slider from '../components/materialdesign/VillageSlider';

import TextContents from '../assets/translations/TextContents';


import './Home.css';

class Home extends React.Component {
    
    render() {
        const TheWorldIsYours = 
            <div className="home-full-section">
                <div>
                    <img
                        src= { DiscoverImage }
                        className= "home-discover-background"
                        alt="Village"
                        />
                </div>
                <div>
                    <div className="home-discover-text-container">
                        <h1>{TextContents.ThinkOfUs}</h1>
                        <p>{TextContents.TheWorldIsYours}</p>
                        <div className="button-discover">
                            <WhiteButton textSize="14" link_href="/discover" text={TextContents.DiscoverBtn} />
                        </div>
                    </div>
                    <div>
                    <img
                        src= { VillageBanner }
                        className = "home-discover-banner"
                        alt="Village"
                    />
                    </div>
                </div>
            </div>;

            const CuratedLearning = 
                    <div className="home-section">
                        <h1>{TextContents.CuratedTitle}</h1>
                        <p>{TextContents.CuratedDesc}</p>
                        <BlueButton textSize="14" link_href="/hereisthemission" text={TextContents.HereIsBtn} />
                    </div>;

            const WhatsTrending = 
                    <div className="home-section">
                        <h1>{TextContents.TrendTitle}</h1>
                    </div>

            const WhatsNearby = 
                    <div className="home-section">
                        <h1>{TextContents.NearbyTitle}</h1>
                    </div>


        return (
            <div className="home-container">
                <div>
                    {TheWorldIsYours}
                </div>
                <div>
                    {CuratedLearning}
                </div>
                <div>
                    {WhatsTrending}
                    <div>
                        <HomeCarousel />
                    </div>
                </div>
                <div className="add-space">
                    {WhatsNearby}
                    <div>
                        <Slider />
                    </div>
                </div>
            </div>
                );
        }
}

export default Home;

As for the accompanying CSS:

.home-discover-container{
    width: 100%;
    height: auto;
    border-radius: 21.5px;
}

.home-discover-background {
    width: 100%;
    height: auto;
    border-radius: 21.5px;
}

/* More CSS styles here... */

.button-curated {
    position: absolute;
    text-align: left;
    top: 32%;
}

Therefore, my objective is to present the image, title, text, icon, and button as a cohesive unit ensuring the overall design remains intact. For responsiveness, minor design adjustments may need to be made, such as font changes, to maintain visual appeal across different devices.

Thank you for your assistance.

Answer №1

Enclose it within a div element and define the picture as background-image using CSS. Another technique is to apply position: absolute to the child element and position: relative to the parent element, along with adjusting top and left properties for spacing, creating an aesthetically pleasing display.

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

Utilizing Electron to save editable user data in a .txt file

I am making an electron app that converts data from .txt files to Javascript arrays. This data is stored inside a folder called faces in the main directory. I also have a button in my app which, when clicked opens file explorer at the faces folder so the u ...

Multiple triggers occur when custom component properties are bound

Upon using a custom component with an input property where a function is bound to it, I have observed that the function gets called multiple times. For example: <some-tag [random-input]="randomFunction()"></some-tag> And in the class: priva ...

Navigate back to the previous HTML page while maintaining the existing data without causing a refresh

I have implemented an onLoad function in my HTML page to retrieve data from the server and update table rows using AngularJS ng-repeat. However, I am facing an issue where every time I navigate to another HTML page and return, the onLoad function execute ...

How can I efficiently make a GET request to the server using just plain JavaScript?

What is the most efficient method for making a GET request to the server using pure JavaScript? ...

Tips on importing anime js after it has been successfully installed through npm

Today, I added anime js as a dependency to my package.json file. The version 3.0.1 is visible in the dependencies list. I used npm to install it. Next step was creating a folder and a JavaScript file in the public directory. I set up a simple event liste ...

Tips for passing an object as an argument to a function with optional object properties in TypeScript

Consider a scenario where I have a function in my TypeScript API that interacts with a database. export const getClientByEmailOrId = async (data: { email: any, id: any }) => { return knex(tableName) .first() .modify((x: any) => { if ( ...

Combining the power of Angular with a Vanilla JS web application

Seeking your expertise. Situation We are transitioning from a legacy Vanilla JS webapp to Angular. Our plan is to gradually replace isolated components while adding new functionality as separate Angular apps, all within a timeframe of 6-12 months. Challe ...

Emphasize the search query in Angular 2

I'm a newcomer to Angular 2 and I'm attempting to accomplish a task similar to the one mentioned in the following post: Highlight the search text - angular 2. I have created a pipe filter and my question is, where should I place the pipe filter a ...

Choose a random element from an array and then modify the array

Can someone please assist me with this task? I am creating an array that corresponds to specific question numbers. var arrayCharge = []; for (var i = 2; i <= 45; i++) { arrayCharge.push(i); } I then utilize these numbers to display the respective quest ...

Embedding a picture logo within a CSS-designed content box

I am trying to create a unique layout for my website that reveals content using labelled radio buttons, without the use of scripts. Instead of using <a href='#'>, I want to achieve a specific layout like the one shown in this example. When ...

Ways to retrieve interface definition using a variable

I have an interface that organizes various states together export interface ScanFiltersStatePage1 { keywords: SensitiveInfoFileKeywordFilter categories: string[] classifications: string[] fileTypes: string[] infotypes: string[] regulations: str ...

Building a matrix-esque table using d3.js reminiscent of HTML tables

I would like to generate a table resembling a matrix without numerical values. 1. Here is an example of my database table: | CODE | STIL | SUBSTIL | PRODUS | |------|-------|----------|---------| | R | stil1 | substil1 | produs1 | | R | stil1 | s ...

Eliminate redundant items within an array by comparing their unique identifiers and dates

I am looking to eliminate duplicate object entries based on id, while displaying the most recent object entry based on pubDate. Take a look at my example array below: var arr = [ {fileID: "1234", pubDate: "04/13/2018", id: "49791 ...

What is the best way to implement NgClass on a single iteration within NgFor while utilizing parent/child components?

My goal is to toggle the visibility of tiered buttons when a parent button is clicked. I am using ngFor to generate three buttons on tier 1, but I'm struggling to select only the desired tier when clicked instead of affecting all of them. I've m ...

Struggling to display the sorted array items on the screen?

Within the realm of my jsfiddle experiment, my aim is to organize items based on price from highest to lowest by utilizing the following function: function mySortingFunction() { var elements = [].slice.call(document.getElementsByClassName("price")); e ...

Dealing with multiple modal dialogs in Bootstrap

I am attempting to work with two separate modal dialogs within Twitter Bootstrap. My approach involves duplicating the HTML code for the modal dialog and creating a new button (BTN2) with data-toggle="modal2". When the new button (BTN2) is clicked, the se ...

Using dictionary keys as valid property values

I have put together a dictionary like so: const iconTypesDictionary: { [key: string]: IconPrefix } = { solid: 'fas', regular: 'far', light: 'fal', } My goal is to be able to utilize the keys of this dictionary as potent ...

Displaying multiple Blender-exported objects with their corresponding meshes and materials in Three.js

I recently created two unique objects using Blender, each with their own distinct materials and textures applied through UV mapping. During the rendering process using CanvasRenderer from Three.js, I encountered an issue. When I attempted to export the mo ...

Central peak in an expansive sphere

I'm attempting to mimic the design shown in this visual representation: While I am familiar with how to generate a semi-circle using CSS, my goal is to only create the top central segment of a larger circle. Specifically, I am seeking the CSS code n ...

Ruby on Rails is experiencing a malfunction with the Ajax request

In designing a quiz, I wanted to display the questions one by one in a list. When clicking on a question in the list, it should navigate to that specific question's location. However, I encountered an issue where the loader does not stop loading. Her ...