Including an <a> element in a flexbox layout causes everything to go haywire

How can I add links for each box without causing issues with the "a" tag? What am I doing wrong?

.services-area {
  padding: 120px 0;
}

.container3 {
  display: flex;
  width: 100%;
  min-height: 500px;
  background-color: #fff;
  flex-wrap: wrap;
}

.main-text2 {
  color: #333;
  width: 100%;
  padding: 0 40px;
  margin: 0 10%;
}

.main-text2 h2 {
  text-align: center;
}

.services {
  display: flex;
  width: 100%;
  padding: 2rem 0;
}

.service {
  display: flex;
  width: 30%;
  flex-direction: column;
  align-items: center;
  padding: 45px 55px;
  transition: 0.25s;
}

.service:hover {
  border-radius: 5px;
  cursor: pointer;
  transform: scale(1.1);
  box-shadow: 10px 10px 20px;
  border-color: #fff;
  border: 1px;
}

.link {
  display: grid;
}

.service-image {
  width: 60px;
  height: 60px;
  margin: 0 0 23px;
}

.service-title {
  color: #333;
  font-size: 18px;
  font-weight: bold;
  align-items: end;
}

.service-text {
  margin-top: 1rem;
  font-size: 14px;
  color: #333;
}

.service-price {
  margin-top: 2rem;
  align-self: flex-start;
}

.price-underline {
  text-decoration: underline #999997 2px;
}
<section class="services-area">
  <div class="container3">
    <div class="main-text2">
      <h2>
        We have a wide range of renovation services available
      </h2>
      <div class="services">
        <div class="service">
          <a href="sevice.html" target="_blank" class="link">
            <div> <img class="service-image " src="images/paint-roller (1).png" alt=""></div>
            <p class="service-title">Construction</p>
            <p class="service-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, seagna aliqua maecenas accum lacus vel facilisis.</p>
            <p class="service-price"> Prices from <span class="price-underline">$30/m2</span></p>
          </a>
        </div>
        <div class="service">
          <a href="sevice.html" target="_blank">
            <div> <img class="service-image " src="images/painting.png" alt=""></div>
            <p class="service-title"> Electrics</p>
            <p class="service-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, seagna aliqua maecenas accum lacus vel facilisis.</p>
            <p class="service-price">Prices from <span class="price-underline">$25/point</span></p>
          </a>
        </div>
        <div class="service">
          <a href="sevice.html" target="_blank">
            <div> <img class="service-image " src="images/paint-roller.png" alt=""></div>
            <p class="service-title"> Plumbing</p>
            <p class="service-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, seagna aliqua maecenas accum lacus vel facilisis.</p>
            <p class="service-price">Prices from<span class="price-underline"> $35/point</span></p>
          </a>
        </div>
      </div>

    </div>
  </div>
</section>

Answer №1

To prevent the a tags directly within the .services flex container from being treated as flex items, add the CSS rule below:

.services > a {
   display: contents;
}

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

Trigger jQuery to play audio files

Something seems off with this code. The audio file isn't playing when the webpage loads. $(document).ready(function() { var audioElement = document.createElement('audio'); audioElement.setAttribute('src','content/aud ...

Top strategy for incorporating/displaying extra form fields

Seeking advice on improving user interface design. I want to develop a form that enables users to add more fields by clicking on a "+" or "add" button. For instance, the user can fill out a text field labeled as "Description," followed by another field n ...

What is the best way to create a border with an inside radius?

Looking to design a div with an inner circle in the corner similar to the image below. Seeking assistance to find a solution for this issue. ...

I'm fresh to the world of Angular and I'm looking to display a modal with form details to confirm before submitting the form

Instead of immediately submitting the details when signing up, I would like to show the form details filled by the user in a modal first. The user can then choose to submit the form or go back and edit the details. Using Angular, how can we implement a fe ...

Having trouble with SCSS styles not being applied after refactoring to SCSS modules?

Currently, I am in the process of restructuring an application to ensure that component styles are separated from global styles using CSS modules. However, I have come across an issue where the styles are not being applied correctly. The original code sni ...

Click on the following link to view your screen resolution:

As I work on a website that showcases an animation with a resolution of 1024x768, I plan to distribute the link as a Holiday greeting through email. Is there a method to ensure that the website only loads in the specified resolution, even if the user' ...

observing numerous directories in Sass

Is there an efficient way to monitor multiple directories in sass using a shell script? This is what I currently have in my shell script: sass --style compressed --watch branches/mysite/assets/css/sass:branches/mysite/assets/css & sass --style compre ...

Guide on incorporating a Bootstrap date time picker in an MVC view

Is there a live example available that demonstrates how to implement the latest Bootstrap date time picker in an MVC view? In my project, I have already included: - jQuery. - Bootstrap JS. - Bootstrap CSS. ...

Issue with HTML file not found in Python Tornado AngularJS application (using ui-router)

Looking at my code Folder Structure: App- |--- static | |--- css | |--- js | |--- app.js | |--- templates | | --- header.html | | --- template.html | | --- footer.html | | --- index.html |--- startup ...

Expansive visuals with the Masonry plugin

Looking to create a Masonry layout with images but running into the issue of large image sizes. Wanting to limit each image to 30% of the screen width while maintaining proportionate height. How do websites like Flickr and Pinterest handle this when uplo ...

How can I modify the text color of the Navbar-Brand class in Bootstrap NavBar?

I have been experimenting with various options to change the text color of the `navbar` and specifically the `navbar-brand` item. However, my `.navbar-brand {color: purple;}` CSS class doesn't seem to be working. Can someone please assist me in determ ...

The "maxlength" attribute does not function with the input type "number" in an HTML textbox

The maxlength attribute does not seem to be functioning properly when using type="number" ...

Resolving jQuery complications in the validation of login forms

I've been attempting to validate a form using jQuery and PHP, but none of the tutorials I've followed have worked for me. I'm feeling lost and confused as I've tried multiple approaches with no success. I'm hoping someone can pinpo ...

My desire is to have the left image's position set as sticky

Currently, I am attempting to update the image positioning on this page for the T500 Smart Watch: I want it to look similar to how it appears here: Here is the CSS code I have experimented with: .storefront-full-width-content.single-product div.product ...

When an anchor tag is used to wrap a column in Bootstrap 4, the justify content feature is automatically removed

When I wrap columns in an anchor tag, the justify-content-center class stops working. I even tried wrapping a separate div inside the column and then put that div in an anchor tag, but still no luck with the justify-content-center class that worked fine be ...

What is the reason behind the alignment of Bootstrap's navigation dropdown menu to the right?

Having an issue with my bootstrap dropdown. It seems to work fine, but once I navigate to a page through the menu, things start to look weird: As shown in the image, the menu appears displaced to the right. Here is the code snippet: <div class="navba ...

Fetching data from MySQL to create statistical analysis

Let's start with the technical setup: Server: Apache/2.2.22 (Debian) Php: 5.4.4-14+deb7u9 MySQL: 5.5.38 This website is utilized by employees to monitor their daily tasks. As I began developing statistic pages in html/php for a monthly summary, ...

What is the best technique to incorporate dark/light mode in Bootstrap 5?

Is it best to introduce themes such as dark and light themes in Bootstrap 5 using CSS/SCSS, JavaScript, or a combination of both? Should we create a separate CSS file like dark.css to overwrite classes? Or should we use JavaScript to switch classes like ...

Is there a similar feature to Bootstrap's img-responsive in Zurb Foundation?

Foundation's interchange feature allows you to replace individual images with smaller versions at various screen sizes, but I'm in need of a solution that resizes the images like Bootstrap's img-responsive class used to do. ...

Hiding content with a fixed Bootstrap menu

How can I prevent the fixed menu in my web page from hiding content, especially when the screen size is reduced and responsive menu hides even more content? Here's an example of the code: <nav class="navbar navbar-inverse navbar-fixed-top" styl ...