Is the CSS file not influencing the final result?

Currently, I am following a portfolio tutorial and have encountered an issue. The HTML code seems to be correct, however, the CSS part does not seem to affect the output in my case. I'm unsure of what could be causing this discrepancy. If anyone has any insights, please let me know.

If you'd like to take a look at my repository, here is the link: Porfolio react app

Below is the snippet of my HTML code:

      <h3 className="font-bold">Take a look of our projects</h3>
      <hr />

      <div className="row">

          {projectsdata.map(project => {
              return <div className="col-md-4">
                      <div className="position-relative project">
                        <img src={project.image} alt='' />
                      
                      </div>
                </div>
          })}

    </div>

And here is the CSS code snippet provided:

[.projects-intro .primary-button{
    background-color: blue;
    color: white;
    font-weight: bold;
}

.project{
    padding: 20px ;
    border: 1px solid rgba(0, 0, 0, 0.486);

}
.project img{
    height: 220px !important; 
    width:100% !important;
}]

This is the expected outcome:Image

However, the actual result looks like this:Image

Answer №1

Try adjusting the width first, and then set the height to auto

.project img{
    height: auto; 
    width: 220px;
}

Avoid using !important unless necessary for overriding a third-party library

Using !important is not recommended as it can complicate debugging due to disrupting the natural cascading order in your stylesheets -- Mozilla Specificity

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 extract information from the response of a fetch request in JavaScript using Express and Node.js

Currently, my script code resides in the index.html file, which I understand is not the ideal location. However, I am in the process of getting it to work before relocating it. readOperaciones(); async function readOperaciones(){ try{ ...

How to individually justify flex items in React Native?

I am looking to create a button with the text in the middle centered and an additional text pushed to the right, similar to this image: https://i.imgur.com/oNDeFJo.png I attempted to use the marginLeft property, but the react-native flexbox model behaves ...

Loading several textures at once using THREE.textureLoader in Three.js

After encountering issues with loading textures in a previous post, which can be found here, I decided to follow the recommendations provided in the links and the documentation. This led me to come up with the following solution: var loader = new THREE.Te ...

Apollo client doesn't seem to be handling the UserInputError correctly

When handling an UserInputError in the Apollo server, I noticed that the playground is correctly displaying the error with extensions and exceptions. However, when it comes to the apollo client, the extensions and exceptions are not being shown. ...

disable the form submission function in dropzone when buttons are clicked

Dropzone is being utilized on my page in the following manner alongside other input types such as text and select dropdowns: <form name="somename" method="post" action="/gotoURL" form="role"> // Other form elements here <div id="dropare ...

Creating a responsive div class that is centered

Struggling to center my <div class="loginfeld"> while keeping it responsive. <html> <body> <div class ="loginfeld"> <div class="container"> <div class="col-lg-4"></div> ...

What is the best way to delete a JSON key in PHP?

Is there a way to eliminate the "src" key from this JSON data if it exists within the array? $json = '[{"label":"360","file":"http://aaa","src":"http://aaa"}, {"label":"480","file":"http://bbb","src":"http://bbb"}, {"label":"720","file":"http://ccc", ...

Serializing Form Data with Checkbox Array

I am currently utilizing JQuery to submit a form using the form.serialize method. However, within the same form, there is an array of checkboxes that are dynamically created by a PHP function. Here is the structure of the form: <form class="form" id="f ...

Ways to find the image source using JavaScript/Jquery upon page loading?

I've scoured countless forums, yet a viable solution still eludes me. My objective is simple - upon page load, I want to gather all elements with the ".home" class and store them in an array called arr. Subsequently, the script should iterate through ...

Divs sliding out of alignment

I am experiencing an issue with the scrolling behavior of a wrapper div that contains two nested divs. Specifically, when I scroll the wrapper horizontally on Android devices, the header section and content section seem to be out of sync and there is a not ...

The date entered in an HTML input is being interpreted as "incorrect" by the system

Upon inputting 3/15/2019 as the date and then checking the time with console.log(fromDate), the output appears as Thu Mar 14 2019 19:00:00 GMT-0500 (Central Daylight Time). Why is it not showing Fri Mar 15 2019 00:00:00? Could this be related to the tim ...

When the li is clicked, replicate it and display it in a separate div

When a list item is clicked, I want to clone it and display it in a separate div. If another list item is clicked, the previously displayed item should be replaced with the newly clicked one. Below is my code along with a link to the codepen where you can ...

Eliminate inline CSS using jQuery

Generated by the jssor-slider, this inline CSS includes position: absolute; top: 0px; left: 0px; width: 1500px; height: 700px; transform-origin: 0px 0px 0px; transform: scale(0.876644); I aim to replace it with, position: absolute; top: 0px; left ...

Issue with parsing JSON object within a React component

Within my project, I have implemented three key components. The first is a search bar used to input values for an API query. The second component, mainPage, acts as the central hub, connecting all elements and sending the searched value to the API. Finally ...

Select a file and upload an image promptly after it is chosen

Is there a way to automatically upload an image once a user selects a file in their browser? Similar to how it works on Facebook, where users can choose a file for their cover or profile image and then the upload process begins. Currently, all I have is ...

Creating a full-height application with CSS3 Flexbox and managing overflow

I'm currently working on an app that utilizes a traditional email layout similar to the one illustrated below. Using the new CSS3 flexbox model, everything was functioning perfectly until I added the feature for users to dynamically insert new items ...

What is the best way to use jQuery AJAX to efficiently upload a file to a PHP page

Attempting to write some JavaScript code along with AJAX for file sending technology. Here is the HTML form code: <form action="" method="post" id="contact_form" enctype="multipart/form-data"> <input type="text" name="name" id="name"> < ...

What is the reason behind Checkbox triggering the Tabs onChange event in material-ui?

I've implemented a checkbox inside a tab using Material UI for React. const Layout = () => ( <Tabs value='a' onChange={e => console.log(e)}> <Tab label='a' value='a'> <Checkbox /> </Tab ...

Arranging Bootstrap buttons in a clean row

How can I add two nav buttons "register" and "sign in" to the top right of my navigation bar, and include a separate button "request a demo" below them without displacing the first two buttons? I am currently using a br tag to push the third button down ...

Apply CSS styles conditionally to an Angular component

Depending on the variable value, I want to change the style of the p-autocomplete component. A toggle input determines whether the variable is true or false. <div class="switch-inner"> <p [ngClass]="{'businessG': !toggle }" clas ...