What steps should I follow to make a stunning photo collage using HTML, CSS, and Bootstrap?

I attempted to insert images into the div but encountered difficulties.

<img
                  class="img-fluid"
                  src="https://via.placeholder.com/800x800"
                  style="border-radius: 20px"
                />

As a result, I experimented with adding background images to divs. However, the images were not displaying. Can someone provide me with a solution and explain why this issue is occurring?

<div class="col-lg-6">
            <!-- ??????? how do i create the grid -->
            <div class="row g-0">
              <div class="col-lg-4">
                <div
                  class="imgcollage"
                  style="background-image: url(../img/img2.jpg)"
                ></div>
              </div>
              <div class="col-lg-8">
                <div
                  class="imgcollage"
                  style="background-image: url(../img/img2.jpg)"
                ></div>
              </div>
            </div>
            <div class="row g-0">
              <div class="col-lg-8">
                <div
                  class="imgcollage"
                  style="background-image: url(../img/img2.jpg)"
                ></div>
              </div>
              <div class="col-lg-4">
                <div
                  class="imgcollage"
                  style="background-image: url(../img/img3.jpg)"
                ></div>
              </div>
            </div>
          </div>

Below is the corresponding CSS:

.imgcollage {
  height: 100%;
  width: 100%;
  background-position: center;
  background-size: cover;
  border-radius: 20px;
}

Answer №1

Apologies for the previous post with broken images. The issue was that the images were not actual URLs.

.imgcollage {
  height: 100%;
  width: 100%;
  background-position: center;
  background-size: cover;
  border-radius: 20px;
}
.col-lg-6{
  display:grid;
  /* specifies the number and size of columns, rows, and the gap between them */
  grid-template-columns: 250px 250px;
  grid-template-rows: 250px 250px;
  grid-gap: 15px;
<div class="col-lg-6">
            <!-- How do I create the grid layout? -->
                <div
                  class="imgcollage"
                  style="background-image: url(https://images.pexels.com/photos/2253275/pexels-photo-2253275.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500)"
                ></div>
                <div
                  class="imgcollage"
                  style="background-image: url(https://images.pexels.com/photos/1108099/pexels-photo-1108099.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500)"
                ></div>
                <div
                  class="imgcollage"
                  style="background-image: url(https://images.pexels.com/photos/731022/pexels-photo-731022.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500)"
                ></div>
                <div
                  class="imgcollage"
                  style="background-image: url(https://images.pexels.com/photos/2623968/pexels-photo-2623968.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500)"
                ></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

The challenge of navigating CSS specificity guidelines

In my CSS file, I have defined two styles for a table with the class "myTable". The first style sets the background color of header cells to gray, while the second style sets the background color of odd rows to blue: .myTable th { background-color: gr ...

Avoid displaying "undefined" on HTML page when Firebase database value is empty

I am trying my best to explain my issue, although I struggle with scripts. Please bear with me and help me improve. ˆˆ Below is the script I am working on. The goal is to display all records with a date set for 'today or in the future'. Progr ...

Utilize JSoup to extract data from HTML div elements

After exploring this platform, I have found answers to most of my queries. Thank you for that! However, I encountered an issue while parsing a file containing Football Stat data. The div tag below appears to have multiple nested elements which are perplex ...

Issue with Font Requests in Browsers when Using Angular 10 and SCSS with @font-face

I have a project built with Angular 10 that utilizes SCSS for styling. In my _typography.scss file, I have defined some @font-face rules pointing to the font files located in the assets/fonts directory. However, when I run the application, the browser does ...

Troubleshooting the Full Height Feature for Sidebar (Panel) in Twitter Bootstrap

I'm having issues with the Sidebar (Panel) in Twitter Bootstrap. I'm encountering some trouble with how it is displayed. Below is the CSS code I am using for the sidebar: .sharecartside .content { height: 100% !important; min-height: 10 ...

"Skip the inbox clutter and access the compose page directly on Gmail, Yahoo, and

I was looking to create a unique hyperlink that would direct users to a compose page similar to Google Mail. Here is an example of what I tried: <li><a href="https://inbox.google.com/mail/?view=cm&fs=1&<a href="/cdn-cgi/l/email-protect ...

Safari not supporting SVG with pointer events

When working with SVG elements (shapes), I often encounter situations where mouse clicks need to pass through transparent areas or where there is no actual shape present. To address this issue, I have utilized the css property pointer-events:none on the r ...

Chrome on IOS: Experiencing screen freezing while scrolling

1) I'm working with Material UI in React JS. I have added a simple scrollable code, but when I reach the bottom of the screen/scroll, it freezes. 2) I also tried it with a simple HTML page and it worked correctly. <div style={{ ...

Automatically updating the results section while executing SQL queries in PHP

Here is a JavaScript/Ajax code snippet: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready (function () { var updater = se ...

What is the best way to apply a background image to a DIV element using CSS

The main aim is to change the background image of a DIV using AJAX. $.getJSON("https://itunes.apple.com/search?term=" + searchTerm + '&limit=1' + '&callback=?', function(data) { $.each(data.results, fun ...

Buttons in HTML function properly on desktop but are ineffective on mobile devices

My website is almost complete, but I am facing some challenges with the mobile version. All buttons that use JavaScript are not functioning properly, whereas buttons with simple links work perfectly fine. This issue doesn't occur on Chrome when using ...

What is the best way to keep a text editable in a razor editor without it vanishing?

I'm on a quest to find the name for a certain functionality that has been eluding me, and it's truly driving me up the wall. Check out the razor code snippet I've been using to exhibit my form inputs: <div class="col-sm"> ...

Double dragenter events triggered before dragleave in HTML5 drag and drop functionality

Currently, I'm researching HTML5 Drag and Drop functionality by using this resource. However, I've encountered an issue with the dragenter event that seems to fire twice for child elements before the dragleave event. Because of this, the dashed b ...

Changing the class of an element using CSS when hovering over another

Is it possible to dynamically change the style of another element when hovering over a specific element? For example, I want a menu item to change its appearance when hovering over a submenu item. Here is the CSS code I have: ul.menu .menulink { padding ...

What type of JavaScript scope is accessible by an anchor tag's href attribute?

My current query involves using an <a> tag to invoke a JavaScript function: <a href="javascript:doSomething();">link</a> In which scope does this JS function need to be defined in order to be reachable? Is declaring it globally necessar ...

What is the process for adding an SVG image (icon) to the navigation bar of a Quarto document?

I am trying to incorporate an SVG icon into the navigation bar using Quarto, but I am facing difficulties in getting it to work. The code snippet from my _quarto.yml file looks like this: navbar: ... right: - icon: github href: https://github.com/ ...

Tips for overlaying an image on a div regardless of its height

(!) Although this question may seem repetitive, I have not been able to find a suitable solution in any of the previous 10 topics. I apologize for the inconvenience and am actively seeking a resolution to this unique situation; Allow me to outline the iss ...

What is the best way to position a grid of divs in the center?

To elaborate on the issue in depth, I need to establish a few assumptions: I possess a list of items with an unknown length (can range from 1 to 50 or more). My objective is to exhibit these items in a grid format, where the number of items per row varie ...

Gliding along a div and concealing it out of view, making it seem like it has disappeared

I attempted to slide down the ".preloader" div after a 2-second delay using JQUERY, but I couldn't get it to work as expected. I didn't want to use a toggle button for this effect. I also experimented with creating an animation using @keyframes, ...

Only half of the image is responsive to hover effects

Just starting out with coding and running into an issue... My social media icons are supposed to turn pink on hover using a second image, but for some reason it's only showing up on the bottom half. Any suggestions? CSS: a.twitter:hover { backgr ...