Developing an adaptive image for a specific segment

I've been racking my brain trying to figure out what obvious mistake I made on this basic website. I need the image below the header to be responsive, but no matter what I try, it just won't cooperate.

If someone could help me out, I would really appreciate it. Thanks in advance!

Here is the HTML code:

<html>    
<body>

      <header>
        <div class="container">
          <div class="brand">
            <img class="brandImg" src="https://photos-1.dropbox.com/t/2/AACo_XuN80WW6m3RltLuUDD-Koivyw205OCV55h43hevVQ/12/184045382/png/32x32/1/_/1/2/network.png/EKPi4YsBGMICIAIoAg/u6N5dEYvNDRNysVhT6Arx-eKOa64tOkilzRp8K3e93Y?preserve_transparency=1&size=1600x1200&size_mode=3" alt="Brand Image">
            <h3 class="mainTitle">Network Solutions</h3>
          </div>
          <nav>
            <ul class="navBar">
              <li><a href="#">About |</a></li>
              <li><a href="#">Portfolio |</a></li>
              <li><a href="#">Contact</a></li>
            </ul>
          </nav>
        </div>
      </header>

      <section id="showcase">
      <div class="heroImg">
        <div class="container">

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

 </body>
 </html>

And here is the CSS code:

/* MAIN STYLES */
.container {
  max-width: 60%;
  margin: 0 auto;
}

/* HEADER */
header {
  height: 100px;
  border-bottom: 2px solid black;
  border-top: 2px solid black;
}

.brand {
  float: left;
  display: inline;
  margin-top: 20px;
}

.brandImg {
  height: 4em;
  width: 4em;
  float: left;
  margin-bottom: 5px;
}

.mainTitle {
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.2em;
  position: relative;
  left:8px;
  top: -5px;
}

/* MAIN NAVIGATION */
ul {
  float: right;
}

li {
  margin-top: 15px;
  float: left;
  display: inline;
  font-size: 40px;
  padding-left: 15px;
}

a {
  color: #000;
  text-decoration: none;
}

a:hover {
  color: gray;
}

/* HERO SECTION */
#showcase {
  width: 100%;
  height: 100%;
}

.heroImg {
  background-image: url("https://photos-1.dropbox.com/t/2/AADgiVKPX---q_yzz3R6QXjMuvUF9x1suRGMjLMV8QkZVQ/12/184045382/jpeg/32x32/1/_/1/2/hero.jpeg/EKPi4YsBGMICIAIoAg/-UTK8zUqda_wA3F-VrZAdIZvo84OHHGWCbLEcdCi1K8?size=1600x1200&size_mode=3");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

Codepen link

Answer №1

The logo image on your webpage is generating a 403 error. Typically, you can create a responsive image using the following CSS:

img {
    display: inline-block;
    max-width: 50px; /* Define your image width */
    max-height: 50px; /* Define your image height */
    width: 100%;
    height: auto;
}

Try this JSFiddle example to see how the image responds when the window size changes.

img {
        display: inline-block;
        max-width: 650px;
        max-height: 250px;
        width: 100%;
        height: auto;
    }
<img src="http://via.placeholder.com/650x250" alt="Test Image Example" />

Another way to make an image responsive is by using Flexbox in relation to another element:

#test {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
}
img {
  display: inline-block;
  max-width: 250px;
  max-height: 150px;
  width: 100%;
  height: auto;
}
h1 {
  margin-left: 15px;
  -webkit-flex: none;
  -ms-flex: none;
  flex: none;
}
<div id="test">
  <div id="logo">
    <img src="http://via.placeholder.com/250x150" alt="Test Image Example" />
  </div>
  <h1>This is a Test Title</h1>
</div>

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

I am facing an issue where my Javascript hide and show function is not working properly when clicked. Despite not giving

I am currently working on a Javascript onClick function to toggle the visibility of content in a lengthy table. I initially set part of the table's class to display: "none" and added a button to show the hidden content when clicked. However, nothing i ...

the function does not wait for the DOM content to finish loading

As I execute the code, an error occurs stating that setting innerText of Null is not allowed. I understand that this is because my function runs before the DOM is completely loaded, but I am unsure of how to resolve this issue. Attempts have been made usi ...

Troubleshooting: @media query's max-width CSS property not functioning as expected

(The styling works on all browsers except Chrome) I am trying to apply a specific style only when the browser width is less than 1400px Unfortunately, using max-width is not producing the desired effect @media only screen and (max-width:1400px) { .head ...

Add a border to the progress bar that has no content

I have configured a Bootstrap Progress Bar with the following code snippet: <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax=& ...

What specific CSS element should be modified in order to effectively style the previews of WordPress posts?

Looking for some guidance here as a new website manager who is also a novice programmer. I need help fixing the issue of post teaser text overlapping with other elements on the page. My plan is to set a specific image size so that even if the featured imag ...

When an image is a child of the parent content and another element has opacity set, the CSS stack order will be altered

Recently, I came across an interesting issue while working with CSS, particularly with negative margins to stack elements on top of each other. I am aware of the natural stack order in which elements overlap, where the later element always appears on top ...

The shopping cart is unable to display the name property as it is undefined

I'm currently working on creating a basic shopping cart using JavaScript. $('.addToCart').click(function(event) { event.preventDefault(); var name = $(this).data('name'); var price = Number($(this).data('price')); ...

Struggling to use GSAP to control the timeline with my custom functions

I'm attempting to create a greensock animated banner with the ability to switch between different scenes. I've made progress by setting up the timeline for each scene's intro and outro animations using the GreenSock API documentation. Howeve ...

After checking the checkbox to add a class, I then need to remove that class without having to interact with the entire document

When I click on a checkbox, an animation is added to a div. However, I am struggling to remove this animation unless I click elsewhere on the document. The goal is for the checkbox to both add and remove the class. JS $('#inOrder').click(functi ...

"Trying to activate a hover effect on a div using JQuery, but it's not functioning

Is there a way to make these divs animate each time I hover over them? Currently, the animation only works once and does not repeat when hovering again. Can anyone provide guidance on how to achieve this? function Rotate() { $('#gear1,#gear2,#gea ...

Ways to widen CSS style in an HTML file in order for it to be visible across the entire page when viewed in a browser

I am trying to make my div stretch across the entire width of the web browser window. However, I noticed that when I scroll to the right side of the page, the div style gets cut off. .div3{ background-image: url('images.jpeg'); b ...

``How can I apply styling to a child component in React within a regular HTML element?

I'm currently learning React and faced a unique situation while working on projects. Here's the scenario - I have two React child components nested under a standard HTML element. If I need to target and style each individual React child element ...

jquery form submission issue unresolved

I am currently utilizing jQuery version 1.10.1 and here is a snippet of my HTML code: <li> <a href='' id='logout'>Log Out</a></li> <form id='logout_form' method='post'> <i ...

What is the best way to adjust the height and width of a div when it comes into view through scrolling?

How can I automatically and frequently change the size of my div when it is scrolled into view? HTML <div id="contact" class="fadeInBlock"> <div class="map"> <div class="pointer"> <div class="dot"></div& ...

Creating inline form groups within a form

Hey there! I'm looking to align the divs with class="form-group" so that their labels are on top, rather than inline with the fields. Currently, they are stacking on top of each other like this: https://i.sstatic.net/rNoS3.jpg I want them to appear ...

Enhance user experience with dynamic color changes in JavaScript

Looking to create a navigation menu with unique colors for each selected state? Check out the code below! After searching extensively, I stumbled upon this snippet. While it only includes one selected state, you can easily customize it for three different ...

Ways to implement CSS styling to every input element excluding inputs located within list items of a specific class

input.not(li.tagit-new >input) { background-color: lightgrey; } <ul id="tagAdministrator" style="width: 505px" class="tagit ui-widget ui-widget-content ui-corner-all"> <li class="tagit-new" style="box-shadow: none;"> <input ty ...

Creating a React component that can dynamically render either an image or a video based on the incoming API data is a great way to

I'm currently immersing myself in learning and honing my skills in React. My goal is to develop a React web application that enables users to view and scroll through Nasa's picture of the day based on their selected date. The API I will be utili ...

Several bootstrap dropdown menus - issue with menu not closing when switching between them

Below are the script and style includes that I am using: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script& ...

Employing Bootstrap, incorporate a vertical divider in the center to split three icons on the left and three icons on the right, all while ensuring the design remains responsive

I have been struggling with a layout issue for the past couple of days and I am in need of assistance from someone who can help me. Unfortunately, I am unable to upload an image here as I am new and do not yet have enough reputation points. The Layout Str ...