Tips for establishing a fixed point at which divs cease to shrink as the browser size decreases

There are numerous dynamically designed websites where divs or images shrink as the browser size decreases.

A great example of this is http://en.wikipedia.org/wiki/Main_Page

The div containing the text shrinks proportionally to the browser size until it reaches a certain point, at which it stops shrinking and begins to cover the text boxes.

I am interested in implementing this effect in a JSFiddle project I am currently working on: http://jsfiddle.net/MrLister/JwGuR/10/

If you expand the size of the fiddle, you will observe how the images adapt dynamically. My objective is to make them stop shrinking at a specific point and instead start covering or collapsing on the pictures. This is necessary because when they become too small, the text on each image starts overlapping, creating an undesirable appearance.

Below is the CSS code for the Fiddle:

.figure {
    position: relative;
    display:inline-block;
    max-width: 33%;
}

.figure .figcaption {
    text-align: center;
    height:0;
    top: 40%;
    width: 100%;
    font-size: 55px;
    color: white;
    position: absolute;
    z-index: 1;
}

.figure img {
    display: block;
    max-width: 100%;
}

Answer №1

To prevent items from shrinking, simply add a minimum width using the min-width property.

For example:

.figure {
    position: relative;
    display: inline-block;
    max-width: 33%;
    min-width: 150px;
}

Check out the updated demonstration here: http://jsfiddle.net/jakelauer/JwGuR/13/

Answer №2

  The minimum width should be set to at least 500px; 

This setting ensures that the window will not resize smaller than 500px in width. http://jsfiddle.net/KpRtS/23/ Once the window reaches 500px wide, the images no longer resize.

Answer №3

Learn how to utilize media queries in your CSS code by defining minimum and maximum widths for different scenarios. Check out this resource for more information: http://css-tricks.com/css-media-queries/

img{
    width:100%;
}

@media all and (max-width: 699px) {
  img{
    width:500px;
  }
}

This example showcases a simple way to adjust the layout of your webpage for mobile or tablet views using media queries instead of just relying on a min-width property.

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

scrollable header within the confines of the container

I have been trying to find a solution for my scrolling issue, but I just can't seem to get it right. I want the content within a div to scroll inside its container without affecting the header. Here's the updated JSFiddle link with the jQuery cod ...

Incorporate jQuery UI Datepicker with the ability to trigger an Ajax function upon selecting a

Is it possible to execute Ajax on date select from a datepicker and how can I handle it? I am not receiving any errors in the console regarding the Ajax part. Instead of getting the pro-rated subscription value, I am seeing "success" in the div with ID &ap ...

What is the correct way to show a JavaScript response on the screen?

Here is the JavaScript code I used to call the server API: <script type='text/javascript'> call_juvlon_api(apikey, 'getAvailableCredits', '', function(response) { document.getElementById('show').innerHT ...

Did I incorrectly associate the function with the button causing it to always be executed?

I am working on a PHP page, where I have some initial content followed by session initialization code: <?php session_start(); ?> The requirement is to display a disconnect button only if the user is logged in, indicated by the presence of $_SESS ...

Detecting Image Loading with Javascript

My website is filled with numerous images categorized into 5 different groups, causing it to load slowly. To improve loading times, I have assigned each image a "data-src" attribute containing its actual source. Then, when a specific category is selected ...

most effective method for establishing a relationship between a variable and its corresponding identification number

When retrieving results from a database with a simple PHP while loop, one of the data pieces includes a number that links to another table where the corresponding value is stored. While there are various ways to link this information and display the relate ...

Event that occurs when modifying a user's Firebase Authentication details

Monitoring User Actions with Firebase Authentication Within my application built using Angular, Node.js, and Firebase, I am seeking a method to track user events such as additions, modifications, and deletions. Is there a mechanism to recognize when a us ...

What is the best way to retrieve the response from an Observable/http/async call in Angular?

My service returns an observable that makes an http request to my server and receives data. However, I am consistently getting undefined when trying to use this data. What could be causing this issue? Service: @Injectable() export class EventService { ...

Arranging elements on top of a fixed element using JavaScript and CSS

Currently, I am implementing Javascript code that adds a div to the body of pages. The purpose of this div is to always stay at the top of the document or window, regardless of the page's design and content. Everything was functioning correctly until ...

Parallax Effect in CSS Background

I am currently working on my website at and have implemented a "parallax-bg" class to create a parallax background effect. Interestingly, the parallax effect is working flawlessly for the hero section at the top and the texture in the middle, but it&apos ...

Are there any images included in the WebResponse being downloaded?

I need to download HTML efficiently in order to parse it with minimal bandwidth consumption. Here is a snippet of my code: if (!String.IsNullOrEmpty(siteAddress)) webReq = WebRequest.Create(siteAddress) WebResponse webRes ...

How to encase HTML content within a scope variable without relying on ng-bind-html

Is there a way to include HTML content using a scope variable in AngularJS without utilizing ng-bind-html-unsafe? <div ng-controller="dataController">{{test}}</div> $scope.test = "<div>Html content</div>" ...

Unclip and clip back element when the hash changes

I am currently in the process of understanding how to properly use detach(); and could use some clarification. My goal is to detach an element that has a dynamically added attribute when the document has a specific hash, and then reattach (?) the element ...

Synchronize Protractor with an Angular application embedded within an iframe on a non-Angular web platform

I'm having trouble accessing elements using methods like by.binding(). The project structure looks like this: There is a non-angular website | --> Inside an iframe | --> There is an angular app Here's a part of the code I'm ...

Components in array not displaying in React

I've been struggling to generate a table from an array in React. Typically, I retrieve data from a database, but for testing purposes, I manually created the array to ensure the data is correct. Despite following examples by enclosing my map code with ...

Error message: "Window object not defined during NextJS build process."

Why am I encountering a 'window not defined' error? I haven't referenced window or document in my code, and it runs without issues during development but throws an error during the build process. ReferenceError: window is not defined at ...

Tips for preventing duplicate properties in Material UI when using React JS

Incorporating components from Material-UI, I have designed a form where the state of inputs is controlled by the parent component. However, I encountered an error stating "No duplicate props allowed" due to having multiple onChange parameters. Is there a w ...

Ways to invoke a prop function from the setup method in Vue 3

I encountered the following code: HTML: <p @click="changeForm">Iniciar sesion</p> JS export default { name: "Register", props: { changeForm: Function, }, setup() { //How do I invoke the props change ...

Tips for effectively interpreting a json string

Trying to extract specific fields from a JSON string and display them on an HTML page, but encountering the following error: SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data This is the JSON being sent: { "Order0& ...

Searching for automobiles using PHP and Ajax technology

During the development of my point of sale system, I encountered a problem with the search functionality. When entering the product code into the designated textbox, I intended for it to automatically search and display the product name and price in the co ...