Difficulty adjusting image size in "layouts with overflowing images on cards."

I have encountered an issue with resizing images on my browser using a card-based layout that I found on codepen. The strange thing is, the image resizing works perfectly fine on codepen itself, but when I try to implement the same HTML and stylesheet on my browser, the changes do not reflect on the image within the "{ img" section like they did on codepen. While I was able to adjust the margins of the card wrap to achieve the desired appearance, I am still puzzled about what could be causing this problem. Any insights would be greatly appreciated. Thank you!

<!--DOCTYPE html-->
<html lang="en">
<head>
<html>
    <link href="home.css" type="text/css" rel="stylesheet" />
        <title>Purple Moss</title>
            <!-- inspiration: https://dribbble.com/shots/3784003-Plant-description-page -->
<div class="wrap">
  <div class="card">
    <div class="card-pic-wrap">
      <img src="https://imagizer.imageshack.com/v2/320x240q90/922/MeU4GZ.png" alt="A leafy plant">
    </div>
    <div class="card-content">
      <h3>summary:</h3>
      <p>Blossom dorset heath scabious ipsum. Grape hyacinth bee balm bird of paradise obedient plant african lily lily. Spring foxglove florist’s nighmare primrose.</p>
      <p><a href="#0">So leafy</a></p>
    </div>
  </div>
  <div class="card">
    <div class="card-pic-wrap">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1145795/plant-4.png" alt="Some pointy plants">
    </div>
    <div class="card-content">
      <h3>Some pointy ones</h3>
      <p>Florem ipsum sugarbush bloom red rose waxflower coneflower ginger. Saxifrage forget-me-not obedient plant.</p>
      <p><a href="#0">I'll take 10</a></p>
    </div>
  </div>
</div>
</html>

/* CSS */

$b-r: 5px;

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}
body {
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: "Courier New", Courier, monospace;
}
.wrap {
  height: 100%; 
}
.card {
  display: flex;
  flex: 0 0 auto;
  background: #fff;
  max-width: 700px;
  margin: 80px 0;
  border-radius: $b-r;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.card-pic-wrap {
  border-radius: $b-r 0 0 $b-r;
  width: 200px;
  flex: 0 0 auto;
  position: relative;
  background: linear-gradient(to bottom, #f5e4b5, #a19ad9);
 img {
    position: relative;
    bottom: 3em;
    left: 50%;
    margin-left: -175px;
    width: 350px;
    -webkit-box-reflect: below -1px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(90%, transparent), to(rgba(250, 250, 250, 0.15)));
  }
}
.card-content {
  padding: 3em 4em 2em;
}
h3 {
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  font-size: 2.5em;
  margin: 0 0 1em;
}
a {
  background: #f5e4b5;
  color: #15077d;
  padding: 0 25px;
  height: 50px;
  font-size: 0.8em;
  letter-spacing: 1px;
  line-height: 50px;
  display: inline-block;
  border-radius: 25px;
  text-decoration: none;
  margin-top: 1.5em;
  text-transform: uppercase;
  border: 1px solid rgba(0,0,0,0.1);
  &:hover {
    background: #15077d;
    color: #f5e4b5;
    border: 2px dotted #f5e4b5;
  }
}
@media (max-width: 790px) {
  body {
    overflow-x: hidden;
  }
  .wrap {
    margin-left: 20px;
    margin-right: 20px;
  }
  .card {
    flex-direction: column;
    margin-top: 50px;
    margin-bottom: 50px;
  }
  .card-pic-wrap {
    width: 100%;
    border-radius: $b-r $b-r 0 0;
    img {
      bottom: 20px;
      position: relative;
    }
  }
  .card-content {
    padding: 2em 2em 1em;
  } 
}

Answer №1

It appears that I have located the problem after all. In the template code I found on Codepen, I noticed that the "img {" was mistakenly placed within the ".card-pic-wrap {" without a proper closing bracket "}." Instead, both elements were closed off with double brackets, causing it to work correctly in Codepen but not in the browser.

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

Are you experiencing issues with the .submit() function when used in conjunction with other

Currently, I am working on a survey form that incorporates JQuery to dynamically display or hide fields based on user selections. //FORM CONDITIONALS: This script is responsible for hiding all the helpfulness radios and only displaying them when "Yes" fo ...

Choosing the right framework for implementing push notifications can be a critical decision. Should

I am currently working on a Java application that requires the server to send push notifications to the client every one second. To achieve this, I am using HTML5 server-sent events for one-way communication from the server to the client. However, my conce ...

Checking the opacity with an if/else statement, then adding a class without removing the existing class

This function is designed to check the opacity of the header, which fades out as a user scrolls down. If the opacity is less than 1, it disables clickability by adding the class "headerclickoff". However, there seems to be an issue with removing the clas ...

How can you show several copies of an image on an HTML page?

I am trying to show an image multiple times in a row using a combination of HTML, PHP, and CSS. Here is my code snippet: for ($i=20; $i<=320; $i=$i+300) { echo "<style> " . ".test{" . "position: absolute; left: " . $i . ...

Is it possible to integrate a standard drop-down menu/style into a MUI Select component?

I am currently working on implementing the default drop-down menu style for my MUI Select Component. Here is the desired menu appearance: https://i.stack.imgur.com/GqfSM.png However, this is what my current Select Component looks like: https://i.stack. ...

Expanding Beyond Boundaries: Utilizing CSS to Overflow From a Div and Fill the Entire Screen

I have a main DIV that acts as part of my responsive layout grid. It grows to the maximum width I've set, which is 1280px, and then adds margins for larger devices. Below you'll find my CSS along with a snippet of Less code. .container { mar ...

Is there a way to utilize PHP/HTML to exhibit a diverse array of random images as dynamic background visuals?

I'm currently learning the process of constructing a website. I've successfully constructed the index page, and below you will find the PHP and HTML code: <?php session_start(); $pngFiles = array('image1.png', 'image2.jpeg' ...

Set the position of a div element to be fixed

I am currently working on a straightforward application that requires implementing a parallax effect. Here are the methods I have experimented with so far: - Inserting an image within a div with the class parallax. - Subsequently, adding an overlay div ...

How can a JavaScript function be used to check a tag's status?

I currently have two select tags on my webpage. I want to ensure that only one option can be selected at a time from these two tags. If the user tries to select options from both tags, an error message should be displayed instructing them to choose only on ...

I encountered an error stating "angular not found" when attempting to dynamically load my Angular scripts

My Angular application is running smoothly. However, I found it tedious to include multiple script tags in my HTML documents every time. To simplify this process, I decided to create a small script that would automatically generate the necessary tags for m ...

Creating a versatile TailwindCSS grid that can adjust to varying numbers of grid columns

I am currently working with Vue3 and TailwindCSS, attempting to create a grid using a dynamic grid-cols-{n} class. While I am aware that TailwindCSS typically supports up to 12 columns by default, the challenge arises when the number of columns needed is e ...

Is it possible that images appear normal locally, but become stretched once deployed? (CSS/HTML only)

I designed a straightforward webpage using only HTML and CSS. Everything looks great when I view it on my local machine. However, once I deployed the site on Droppages, a static-page hosting service integrated with Dropbox, all my images became stretched ...

Is there a more efficient approach to applying a basic function to multiple elements within a DIV and having it activate only upon a click event using jQuery?

This solution works, but I am looking for a more professional approach in order to adhere to the principle of "don't repeat yourself." $("document").ready(function(){ $(".child").each(function(index){ $(this).click(func ...

Is there a way to create a transparent background for my website without affecting the visibility of the content such as images and text?

I'm currently working on a website for a school project, and I've run into a minor issue. I can't seem to make the background of the body transparent without affecting the content within it. Below is my HTML code: <html> <head> ...

Three Divisions Positioned at the Top, Middle, and Bottom

I need to place 3 divs at the top, middle, and bottom positions. To achieve this, I have used jQuery to calculate the viewport height and apply a percentage of it to the top and bottom divs. However, resizing the page causes issues as the middle div overl ...

Troubleshooting problem with displaying HTML content on Internet Explorer 10

My website was developed using jquery with a dynamic coding style. It was functioning properly in IE10 while working from Visual Studio. However, after deploying it to the production server, the entire style seemed broken in IE10. In all other versions o ...

The React JSX error message "Maximum update depth exceeded" occurs when there

It appears that I am facing an issue of creating an infinite loop while passing props from one class to another. Despite ensuring that the buttons are correctly bound and trigger only once, the problem persists without any solution in sight after thorough ...

What are the steps to changing the navbar's color when scrolling down?

I am having trouble changing the color of my navigation bar from transparent to black after the user scrolls down. Despite trying various methods and watching tutorials, I can't seem to get it to work. HTML <nav role='navigation' class= ...

Tips for limiting users to inputting only alphanumeric characters and excluding special characters in an input field using Angular 8

How can I prevent users from inputting special characters in an input field and only allow alphanumeric values? The code that I have implemented so far does not seem to be working as intended. When a user enters a special character, it still shows up in th ...

The container that utilizes the grid layout is compact and has a near-invisible height

grid-template: display; font-style: "Josefin Sans", sans-serif; size-of-text: 10px; element-height: 0px; spacing-bottom: 0px; spacing-left: 0px; spacing-right: 0px; spacing-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-up: 0 ...