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

What is the best way to create a repeating Jquery loop in code?

Hey there! I've been working on creating a button that toggles the background color from white to yellow and back again using Jquery. However, I've hit a bit of a roadblock with implementing a loop function. If you'd like to take a look at m ...

What is the best way to position a rectangle on top of a div that has been rendered using

I recently started using a waveform display/play library known as wavesurfer. Within the code snippet below, I have integrated two wavesurfer objects that are displayed and positioned inside div elements of type "container". My goal is to position my own ...

Create code with a form button and showcase the produced code on the webpage

I have created two files: code_generator.html, which takes input in the form of an image URL and landing URL. When I click on the submit button, it calls code_created.php. <html> <head> </head> <body> <form a ...

Adding an iframe with inline script to my Next.js website: A step-by-step guide

For my Next.js project, I have this iframe that needs to be integrated: <iframe class="plot" aria-label="Map" id="datawrapper-chart-${id}" src="https://datawrapper.dwcdn.net/${id}/1/" style="width: ...

Adjust the size of the container DIV based on the content within the child DIV

I have been searching for a solution to my question without success. Here is the issue: I have a DIV that acts as a container for a Post in my project. Inside this post are classes for the poster avatar, name, timestamp, text, and more. The problem arise ...

What could be causing a react element to fail to update?

I'm currently working on a React component that interacts with a MaterialUi text form. The component utilizes a useState hook to update based on the input received. My goal is to have another variable update when the form is submitted, which will be d ...

Retrieving PHP variables within the HTML document of the current page

Suppose I have a page with a link <a href='edit_info.php?id=1001'>1001</a>. In the edit_info.php page, I want to use this id to query a database, like so: SELECT * FROM table WHERE id = $_GET['id'] Now, I need to populate ...

Navigating a roster of users in JavaScript

I'm dealing with a collection of user data stored in an array accountsade: [ { id: 0.4387810413935975, name: "Adrian", password: "345", userName: "nathanael" }, { id: 0. ...

Is it possible to conceal and completely empty the TextBox once the checkbox is deselected?

When the checkbox is checked, the textbox is displayed; otherwise, it remains hidden. However, the value is not being cleared. Can someone please help me with this issue? Thank you in advance. HTML <div class="munna"> <in ...

Safari on iOS 11.4 ignoring the 'touch-action: manipulation' property

I ran into an issue while developing a React web app that I want to work seamlessly across different platforms. My goal was to allow users to interact with a div element by double-clicking on desktop and double-tapping on mobile devices. However, when tes ...

A guide on showcasing the compilation results of PHP code directly on the web browser

How can I compile PHP code on an HTML Button click and display the compilation output in a browser? The code snippet below works well in the terminal but doesn't show anything in the browser. I am currently using XAMPP server on a Windows machine. &l ...

When the screen is resized, the embedded iframe moves smoothly to the left side

I recently created a projects page, but I am facing an issue with the iframe embed. Whenever the screen is resized, it keeps shifting to the left. However, what I really want is for it to be centered instead of being on the left side: https://i.stack.imgu ...

Crafting an iframe that dynamically adjusts with Tailwind CSS

I'm having trouble ensuring that an iframe fits properly within a div while using tailwind CSS. I'm struggling to make the iframe responsive, no matter what class I try. Can anyone suggest a class that would help me achieve responsiveness for an ...

Employ the v-model directive in conjunction with a checkbox in scenarios where v-for is implemented with the properties of an object

When utilizing v-model with a checkbox in conjunction with an array of objects, it functions correctly: new Vue({ el: '#example', data: { names: [ { name: 'jack', checked: true }, { name: 'john', checked ...

Unable to access .php file on new server using JQUERY AJAX .get

After migrating my website to a new server, I encountered an issue where all the $().get("whatever.php") calls were failing. Previously, everything was functioning properly but now none of the requests are even reaching the php script. For instance: inde ...

After resolving a quirky syntax error in my ejs code, I can't help but ponder what caused the issue in the first place

For my personal web development project, I've been working on a blog webpage to enhance my skills. However, I encountered an unusual syntax error while modifying the code to display different navigation bars for logged in and logged out users. Here&ap ...

Utilizing two distinct CSS frameworks within a single Rails application

At the moment, I have an application with its frontend built using Bootstrap 3 (leveraging the bootstrap-rails gem). Now, I am looking to incorporate the Materialize.css framework into the same app. After downloading the Materialize.css stylesheet, my conc ...

The height set to 100% is causing issues with the padding-bottom property

Currently, I have a setup that includes: A div with width set to 100% and height set to 100% An SVG element inside the div with default width and height of 100% My issue is that when applying padding to the div, the left, right, and top padding seem to w ...

Ways to turn off textarea resizing

Is there a way to prevent horizontal resizing on a textarea while still allowing vertical resizing? I find that the textarea often disrupts the design of my contact us page. If anyone has a solution for disabling the horizontal resize feature, please shar ...

Setting a specific time for a div element with opacity: A step-by-step guide

Is there a way to adjust the timing for the appearance of the add-to-cart when hovering over the product-list-item? Currently, it appears when I hover over the item and disappears when I move my mouse away. .product-list-item { position: relative; w ...