Instructions for creating a row container:

I'm still relatively new to HTML and I am currently in the learning process. However, I am encountering some difficulties when it comes to linking rows and divs.

My goal is to create something similar to the image shown below where each element can be clicked to go to a specific link. I want them to be positioned next to each other, with individual links. I believe using float would work, but can grid also be used for this purpose?

Could someone please guide me on how to achieve this?

I would greatly appreciate any assistance or advice, thank you!

https://i.sstatic.net/q9Dmb.jpg

Answer №1

Website Design

<div class="container">
        <div class="product">
            <div class="bg-white">
                <a href="">
                    <img class="img-fluid"
                        src="https://static.wixstatic.com/media/2c0034_5e484cb9921c41a8bde8eed74b3aa810~mv2.jpg"
                        alt="" /></a>
                <h1>Demo Heading</h1>
                <p>Lorem ipsum dolor sit amet.</p>
            </div>
        </div>
        <div class="product">
            <div class="bg-white">
                <a href="">
                    <img class="img-fluid"
                        src="https://static.wixstatic.com/media/2c0034_84e67efc3df44e8ea8b6da006e6d1ba5~mv2.jpg"
                        alt="" /></a>
                <h1>Demo Heading</h1>
                <p>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet.Lorem ipsum dolor
                    sit amet.Lorem ipsum dolor sit amet.</p>
            </div>
        </div>
    </div>

Cascading Style Sheets (CSS)

<style>
       * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .img-fluid {
        max-width: 100%;
        width: 100%;
        display: block;
        height: auto;
    }

    .container {
        margin: auto;
        max-width: 1200px;
        display: flex;
        flex-wrap: wrap;
        background-color: #f6f6f6;
        padding: 1rem;
    }

    .container .product {
        flex: 0 0 50%;
        padding: 0 1rem;
    }

    .container .product .bg-white {
        background-color: white;
        box-shadow: 0px 0px 15px 5px #ddd;
        height: 100%;
    }

    .container .product h1 {
        font-size: 1rem;
        padding: 0.5rem 1rem .1rem 0;
        border-bottom: 2px solid brown;
        display: inline-block;
        margin: 0 0 .5rem .5rem;
        text-transform: uppercase;
    }

    .container .product p {
        font-size: 1rem;
        padding: 0 1rem 0.5rem 0.5rem
    }
    </style>

Answer №2

To create a visually appealing design, you need to place two div elements with a class of col-6 each inside a single parent div. Within each of these child divs, include two images to enhance the overall look of your layout.

As an illustration:

<div class="row">
<div class="col-md-6">
    <a href="link1">
        <img src="img1">
        <h2></h2>
        <p></p>
    </a>
</div>
<div class="col-md-6">
    <a href="link2">
        <img src="img2">
        <h2></h2>
        <p></p>
    </a>
</div>

Answer №3

Check out this simple demonstration of a two-column design using the flex property on the parent element and setting flex-basis: 50%; on each child element.

.container {
  display: flex;
  justify-content: space-between;
}

.column {
  text-align: center;
  flex-basis: 50%;
  padding: 10px;
  box-shadow: 0px 0px 6px 2px rgba(152, 139, 139, 0.5);
}

img {
  max-width: 100%;
}
<div class="container">
  <div class="column">
    <img src="https://placeholder.com/600x400/c52ac5/fff">
    <h6>Left column</h6>
  </div>

  <div class="column">
    <img src="https://placeholder.com/600x400/2a652b/0011ff">
    <h6>Right column</h6>
  </div>
</div>

Answer №4

Upon creating a container, I included two child elements (image-container and text-container).

Within the image-container, I utilized a background image to cover the container, and established a grid container (image-grid) with four equal frames where the books will be positioned.

Subsequently, I applied margins to the second and fourth child elements:

.image-grid img:nth-child(2){
  margin-top: 1rem;
}

.image-grid img:nth-child(4){
  margin-top: -1rem;
}

html{
  font-size: 25px;
}


img{
  display: block;
  max-width: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}



body{
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  place-content: center;
  margin:0;
  background-color: bisque;
  font-size: 20px;
}

.container{
  width:20rem;
  height:15rem;
  background-color: whitesmoke;
  box-shadow: 0 0 1rem black;
}


.image-container{
  background-image: url(https://source.unsplash.com/random/400x200);
  height: 70%;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.image-grid{
  height: 50%;
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap:1rem;
  margin-inline: 1rem;
}

.image-grid img:nth-child(2){
  margin-top: 1rem;
}

.image-grid img:nth-child(4){
  margin-top: -1rem;
}

.text-container{
  height: 30%;
  margin-block: 1rem;
  margin-left: 1rem;
}

.text-container h2{
  font-size: 0.7rem;
  text-transform: uppercase;
  text-decoration: underline;
}

.text-container p{
  margin-top: 0.5rem;
  font-size: 0.7rem;
}
<div class="container">
      <div class="image-container">
        <div class="image-grid">
          <img src="https://source.unsplash.com/random/600x900" alt="book1" />
          <img src="https://source.unsplash.com/random/600x900" alt="book2" />
          <img src="https://source.unsplash.com/random/600x900" alt="book3" />
          <img src="https://source.unsplash.com/random/600x900" alt="book4" />
        </div>
      </div>
      <div class="text-container">
        <h2>For Pachinko Fans</h2>
        <p>Get Lost in your nex epic family story</p>
      </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

How can you utilize CSS to automatically generate section numbers, specifically for multiple sections?

Is it possible to automatically generate section numbering in CSS only when there are multiple sections present? I discovered that using CSS, one can create automatic numbering for sections. body { counter-reset: section } h2 { counter-reset: sub-section ...

How come my web page is not displaying the guages from guage.js?

I am utilizing guage.js to create a graph based on this Fiddle. However, upon adding the same code to my website, the rendering does not appear as expected: https://i.sstatic.net/fIkQr.png Upon inspecting in Chrome developer tools, I noticed that the ele ...

Obtain HTML content from a loaded JScript frame

I'm in the process of designing a JScript frame and I'm looking to retrieve the HTML content that has been loaded into it. Does anyone have any suggestions on the best way to accomplish this? ...

Referencing another component in StyledComponents

I'm looking to modify the properties of my parent component's :after selector whenever the child element is focused. It seemed straightforward at first, but for some reason, I just can't seem to make it work. Here's a glimpse of my comp ...

Unable to load AngularJS thumbnails from JSON file? Learn how to showcase a larger image by clicking on the thumbnail

Working with AngularJS to retrieve image data from a JSON file has been successful for me. My next task involves loading all of the thumbnail images into the gallery div and populating the src, alt, and title attributes using ng-repeat. However, this part ...

Ensuring that text inside a float left div remains aligned with the left margin

I have a situation where I have three divs that are all floating to the left, displayed like this: (1)(2)(3). The issue arises when the font size within div1 is longer than the width I set, causing it to go to the next line within the div. However, the nex ...

Bootstrap responsive breakpoints for different sizes

As I was optimizing my webpage, everything was going smoothly until I had the idea to incorporate the srcset and sizes attributes into my <img> tags. I developed a php function that generates an img object and populates the srcset attribute with newl ...

What is the most effective method for transitioning between states in Angular when it comes to modifying the HTML display?

When faced with the decision of choosing between two different approaches for managing component view during loading, the "best way" refers to performance and minimizing UI blinking (reducing DOM renderizations). Approach 1: Utilize a loading variable to ...

Javascript Calculator with Dual Input Fields

I have been given a task to create a calculator by tomorrow using Javascript. Unfortunately, I am currently taking a distance course and Javascript has just been introduced in this assignment. While I am familiar with HTML and CSS, Javascript is something ...

What is the best way to position an <a> tag in the top right corner of a card using Bootstrap?

I own a card that features an image in the background. <div class="col-12 col-sm-8 col-md-6 col-lg-4 mt-4"> <div class="card"> <img class="card-img" style=" filter: brightness(75%);" src=& ...

When saving, generate a new object and send it to the designated endpoint

I'm feeling a bit confused, unsure of how to proceed. In my program, the task is to upload images (in base64 format) and add them to an array with a maximum limit of 5. After uploading the images, the next step is to click a button labeled Save to s ...

Create a responsive DIV element within a website that is not originally designed to be responsive

I am looking to optimize the positioning of an ad div on my non-responsive website. The current setup has the ad displayed at 120x600 pixels, always floating to the right of the screen. While this works well for desktop or large devices, the display become ...

For every instance of a repeated value

I am currently developing a file sharing system and facing an issue with displaying the query results in a specific format. When I use print_r(), I can see that the data is as desired, but I am struggling to present it in a neat layout. Here is my databas ...

What is the best way to achieve CSS rounded corners while keeping the border lines sharp?

Currently, I am utilizing the border-radius property to make the corners of a div rounded. In addition, there is a border line at the bottom of the div. Here is an example: <div style="border-radius: .5em; border-bottom: 1px solid black">Content< ...

Drop and Drag File Uploading

I'm currently facing some challenges trying to locate what I need and figuring out how to implement it. At the moment, I have a simple PHP file uploader that works by allowing users to click on a custom upload button, select a file, and using JavaScr ...

What is the best way to distinguish the Footer from the Content?

While I was honing my skills in crafting a website using only HTML and CSS, I encountered an issue. I couldn't figure out how to place the footer beneath the content properly. My goal was to clearly separate each section - header, content, and footer. ...

What is the best way to ensure an image fills the entire space within a Bootstrap modal container?

I'm having some issues with my bootstrap modals that contain images. When the images are long vertically, a scrollbar appears which is not ideal. I tried to solve this by setting a max-height for the modal-content and making the modal-body (where the ...

The art of styling <li> elements compared to <a> elements

While these inquiries may lean towards being subjective, I am interested in learning about the industry's generally accepted best practices: 1) With responsive design and collapsible menus becoming more common, should a nav or nav menu element be sty ...

Fluid Grid design showcasing a gap on the right side

After working on the Skeleton Framework and making adjustments to the grid design, I am facing a small gap issue on the right side. Despite things slowly falling into place, this minor gap is causing confusion. Please refer to the image below for clarifica ...

Error: TweenLite has not been recognized

/justincavery/pen/mPJadb - this is a link to CodePen After copying the code from CodePen and running it, I encountered an error: "Uncaught ReferenceError: TweenLite is not defined". The image only draws once and there is no animation unless I press "F5 ...