Difficulties in Adjusting the Size of Three Image Columns within a Website's Body

While working on my website layout, I encountered a problem with inserting three image columns in the body section. The images turned out to be too large and extended beyond the footer. Moreover, the third image was larger than expected, dominating the webpage width. Despite my efforts, adjusting the height of the images proved challenging, and I could only modify the width of the first two images. To view my code, visit: https://github.com/moseskbalunywa/Stackoverflow

I tried to implement three image columns in the body section but found all images to be oversized. While I managed to alter the width of two images, their height remained unchanged. The last image posed a bigger challenge as it didn't respond to size adjustments. My main resources for this task were ChatGPT, W3Schools, and Stack Overflow. I encountered issues with the following sources: https://www.w3schools.com/howto/howto_css_three_columns.asp How do I create 3 columns with responsive text and images? Chatgpt:

<!-- Your existing code for header and navbar -->

<div class="row">
  <div class="column">
    <img src="images/Castle.jpg">
  </div>
  <div class="column">
    <img src="images/Mascottes.jpg">
  </div>
  <div class="column">
    <img src="images/Crush's Coaster Nemo Attractie afb van een schildpad.jpg">
  </div>
</div>

<!-- Your existing code for footer -->

</body>
</html>
/* Remove any existing styling for .row and .column */
.row {
  display: flex;
  justify-content: space-between;
}

.column {
  flex: 1;
  padding: 10px;
}


/* Rest of your CSS styles remain the same */

.column img {
  width: auto;
  height: 100px;
  /* You can also use max-height to maintain aspect ratio */
  /* max-height: 100px; */
}
.column img {
  max-width: 100%;
  max-height: 100vh; /* Stel de maximale hoogte in op de hoogte van de viewport (zichtbare pagina) */
}

Answer №1

Initially, I experimented with the W3Schools method and it performed successfully for me.

* {
  box-sizing: border-box;
}

/* Establish three identical columns that flow alongside each other */
.column {
  float: inline-start;
  width: 20%;
  display: table;
  padding: 5px;
}

/* Clear any floating elements after the columns */
.row:after {
  content: "";
  clear: both;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="StyleSheet.css" rel="stylesheet">
  </head>
  <body>
      <div class="row">
        <div class="column">
          <img src="https://source.unsplash.com/320x480?computer">
        </div>
        <div class="column">
          <img src="https://source.unsplash.com/320x480?computer">
        </div>
        <div class="column">
          <img src="https://source.unsplash.com/320x480?computer">
        </div>
      </div>
  </body>
</html>

Consider utilizing relative units like rem or em. Employing percentages may also resolve the issue.

Answer №2

Thanks to my helpful classmate, I finally cracked the code! The root of the problem lied in my erroneous attempt to tweak the column instead of the image itself. While the column properties remained untouched, my savvy peer made the necessary adjustments by inserting the image names into my CSS file, incorporating a grid structure within the same file, and establishing a grid layout in my div class. Additionally, he even included a left rem in my css column code for good measure. Behold, the resolution:

<div class="grid">
<div>
  <img id="castle" src="images/Castle.jpg">
</div>
<div>
  <img id="mascot" src="images/mascot.jpeg">
</div>
<div>
  <img id="mascot2" src="images/mascot2.jpg">
</div>

.grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow-x: hidden;
  overflow-y: hidden;
}
#castle {
  width: 125%;
  height: 125%;
  grid-column: 1 / 2;
}

#mascot {
  width: 125%;
  height: 125%;
  grid-column: 2 / 3;
}

#mascot2 {
  width: 125%;
  height: 125%;
  grid-column: 3 / 4;

}

/* Create three equal columns that floats next to each other */
.column {
  float: left;
  width: 300px;
  padding: 10px;
  left: 8rem;

}

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

Looking for a skilled JavaScript expert to help create a script that will automatically redirect the page if the anchor is changed. Any t

Seeking a Javascript expert, In my custom templates, I have used a link as shown below: <a href='http://www.allbloggertricks.com'>Blogging Tips</a> I would like the page to redirect to example.com if the anchor text is changed from ...

Looking for tips on resolving issues with the bootstrap navigation bar?

Check out this code snippet: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport ...

What is the best way to incorporate a progress bar animation into my notification?

Seeking assistance to implement an animated progress bar that changes colors gradually over time based on a variable [timer]. Can anyone lend a hand with this? Thank you! https://i.sstatic.net/lhgeF.png $(document).ready(function(){ window.addEvent ...

Tips for extracting and utilizing a JSON object provided by the parent page:

Sorry in advance if this question has already been addressed. I've spent hours searching on Google, but haven't found a satisfactory answer yet. Below is the code snippet I'm working with: <ion-content> <div class="list"> ...

Adjust the dimensions of the thead, tbody, and td elements on the fly

I've implemented this property in a .css file on the table shown below and there are 9 records. .fixed tbody td, thead th { width: 5.2%; float: left; } In my scenario, when there are 4 columns, the width should be 23.2%; for 5 columns ...

Creating HTML elements using JavaScript compared to importing an HTML fileIn JavaScript,

I am currently in the process of building a website that is entirely driven by JavaScript. Aside from the index page, I do not use any HTML pages at all. Instead, I fetch JSON data for every query and then dynamically generate HTML within the JavaScript to ...

When my webpage is opened in Firefox, I notice that it automatically scrolls down upon loading

I recently embarked on the task of building a website from scratch but ran into an unusual bug in Firefox. The issue causes the page to scroll down to the first div, completely bypassing its margin. I want to clarify that I am not seeking a solution spe ...

When sorting items, the page automatically jumps to the top of the screen

I have been working on creating a sortable portfolio using jQuery. One issue I am facing is that every time I click on a filter for the portfolio items, the page automatically scrolls to the top. Is there a way to prevent this from happening? You can vi ...

Starting the animation only when the slide is visible

Struggling to add animations dynamically as a HTML/CSS developer who avoids JS but uses jQuery occasionally? Sound familiar? Well, I have. Recently, I managed to create a CSS-3 animation for the images in a Bootstrap carousel. Check out the code below: ...

The font appears bolder in Chrome once the CSS animation has finished

My CSS animation is causing some unexpected behavior on page load. Once the animation completes, the text suddenly appears thicker than intended, especially when it's a specific shade of red. Curiously, this strange "popping" effect only occurs with ...

Discover the character "’" as well as other fascinating symbols

When transferring content into an HTML file from sources like Word documents or PDFs, I want to ensure that the special quotes and apostrophes are converted to their standard counterparts. In simpler terms, I desire to switch characters like ’ with &apo ...

Guide on adjusting the darkness of a MaterialUI Avatar component image and adding text to it

I'm currently working with the Avatar component from Material UI along with Tailwind CSS. I found that by simply adding the image URL to the src, it displays the avatar successfully. <Avatar alt="Cindy Baker" src="https://mui.com/sta ...

I currently have two responsive menus and I'm trying to figure out how to modify the javascript so that when one menu is opened, the other

I am facing an issue with my responsive menus on a webpage, similar to the example provided in the jsfiddle link below. Currently, when one menu is open and I click on another, both remain open. How can I modify the JavaScript code so that when one menu op ...

Overlap between sidebar and navbar

I am currently working on developing an admin panel for one of my projects. I designed a sidebar and implemented a standard bootstrap 4 navbar. However, I encountered a minor issue where the bootstrap 4 navbar is extending to the full width of the page ins ...

Firefox is unable to display SWF files

My code snippet: <div id="sw" style="cursor:pointer" > <object id="swfobj" type="application/x-shockwave-flash"> </object> The JavaScript part: function openfile(filePath) { $("#swfobj").attr("data", filePath); $("#sw ...

Setting maximum and minimum zoom limits for an element ID using JavaScript or jQuery

My application features a DIV element with the unique identifier of mainDiv. The issue I am facing is related to zooming functionality, as it currently lacks any set limits - both for scaling up and scaling down. I have been searching on Google for a sol ...

Using the jQuery/JavaScript operator is similar to the SQL LIKE query with the wildcard %

Is there a way to search for a specific part of my input using JavaScript/jQuery? I've tried two different methods, but neither yielded any results. <script type="text/javascript> $("#button").click(function () { $("#DivToToggle").toggle(); ...

The image referenced in the assets folder could not be located within the SCSS

Although I've come across similar questions, none of the solutions provided seem to work for me. I've tried them all, but they just don't seem to do the trick. My goal is quite simple - I just want to set a background image using CSS. Howev ...

Adjusting the width of the body container in a 2-column layout with menu padding is causing gaps to appear on the right side of

I'm having trouble getting my body div to fill the width of the page and align with the right side of my sidebar. Whenever I add padding to the sidebar, it creates blank space on the right that I can't seem to get rid of. Here is the code I am us ...

When printing a PDF, a div that is set to 100vh only takes up

After setting the div to be 100vh, I realized that when printing it only takes up half of the page. Adding media print did not make a difference, and even trying to set the height to 100% instead didn't work for PDFs. html, body { height: 100%; ...