Tips for designing resizable overlay divs

Looking to design an image with an overlay gradient and text, similar to this:

<div>
<img src="url"/>
 <div background-image="other url" background-repeat:repeat-x;>
  <h2>some text</h2>
 </div>
</div>

Some important points:
* Both images should scale correctly in width and height.
* The gradient image is 96px in height and 1px in width.

What would be the appropriate CSS for this kind of overlay? I've tried absolute/relative positioning and setting the top in pixels, but when resizing, the position of the gradient div changes and it no longer aligns to the bottom.

Thank you, Gilad.

CSS

.main{
    text-align:center;
}

.album {    
    width: 100%;
    position: relative;
    margin: 0 auto;
}

.album-cover {
    max-width: 100%;
    display: block;
}

.album-cover-gradient {
    height: 96px;
    background-image: url('../img/text-bg.png');
    background-repeat: repeat-x;
    margin: 0 auto;
    position: absolute;
    bottom: 0;

}

Answer №1

The format you have utilized is incorrect (

background-image="other-url" background-repeat: repeat-x;
) should instead be
style="background-image: url('xxx')"; background-repeat: repeat-x;
.

Nevertheless, it would be preferable to include that in an external style sheet.

You can consider something similar to this:

http://jsbin.com/Odiduce/1/edit

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

HTML: Accept only images in PNG, GIF, and JPG format for file upload

How can I customize the HTML upload dialog window to only show JPG, GIF, and PNG files when users upload an image? ...

The JsHelper::domReady function is malfunctioning!

While developing a website with CakePHP, I have encountered an issue... Utilizing the latest version of jQuery... and using JsHelper to accomplish something like this: $this->Js->domReady ( $this->Js->alert ('Page loaded !') ); ...

Adjust the size of the div to fit its content while maintaining the transition animation

I am aiming for the DIV height to automatically adjust to the text within it, while also maintaining a minimum height. However, when the user hovers their mouse over the DIV, I want the height to change smoothly without losing the transition effect. When ...

I'm noticing my table collapsing as I move around the div elements - any idea why this is happening

A challenge I am facing is creating a dynamic table where users can drag and drop colored boxes with animated transitions. While it mostly works well, sometimes the table collapses inexplicably. Here are steps to reproduce the issue: Move 100 - 400 Move 1 ...

Tips for avoiding re-rendering during onclick event handling

let content=useRef(); let toHide=useRef(); useEffect(()=>{ content.current=document.querySelectorAll('.content'); toHide.current=document.querySelectorAll('.hide'); toHide.current?.[0].addEventListener("cli ...

Issue with opacity transitions in Chrome on React application

I am currently developing a pomodoro clock using React. My goal is to have the message text (e.g. "Set a time", "Focus," etc.) and the play/reset button fade out and in when the play/reset button is pressed. So, when the play button is clicked, "Set a time ...

Locate the final child element within a specified div using JQuery

I am looking to create a web application that allows users to input a question and select from multiple answers. I need to be able to dynamically add extra answer fields when the plus button is clicked, but only within the specific formRow (refer to the co ...

Segment will expand completely upon inserting a new division

Lately, I've been trying to simplify things by consolidating my JavaScript functions into one file instead of using multiple separate files. The idea was to merge all the functions together and wrap each one in its own function so that they can be eas ...

Is a Text-Only View Possible with WebView?

Could someone help me figure out how to restrict a WebView to only load text in my WinRT XAML App? I am looking for a simpler solution than having to download the source and manually editing img tags. ...

Customizing the color of buttons in MUI 4

Currently, I am utilizing mui V4 for my styling and attempting to incorporate an additional color for my buttons. I understand that it only accepts these predefined colors: expected one of ["default", "inherit", "primary", "secondary"]. To achieve this, I ...

Optimizing Window Width with React.js and CSS

I'm currently in the process of building a responsive website with react. I am utilizing CSS stylesheets for styling and have used @media queries to ensure responsiveness. However, I've encountered an issue while testing in Chrome where the elem ...

Whiskey Angostura and Straight Row Set to 8, not 12

Recently, I incorporated Bourbon, Bitters, and Neat into my rails application. However, I am encountering an issue where the number of grid-columns is stuck at 8 instead of the desired 12. To address this problem, I have taken the following steps: Ensur ...

Tips for preventing the appearance of two horizontal scroll bars on Firefox

Greetings, I am having an issue with double horizontal scroll bars appearing in Firefox but not in Internet Explorer. When the content exceeds a certain limit, these scroll bars show up. Can someone please advise me on how to resolve this problem? Is ther ...

Tips for utilizing ng class within a loop

Having some trouble with my template that loops through a JSON file using json server. The issue I'm facing is related to correctly applying ng class when clicking on icons. Currently, when I click on an icon, it adds a SCSS class but applies it to al ...

Discover the step-by-step guide to implementing pagination using NG-ZORRO-Andt in your Angular

I am currently using NG-ZORRO Ant Design pagination on my HTML page and it is displaying correctly in my browser. However, I am struggling with linking the data from the API to the pagination feature. Here is the snippet of my HTML code: <div class ...

I clicked on the Bootstrap Navbar button but unfortunately nothing occurred

I'm encountering an issue with my navbar. When the screen size is reduced, a button appears, but clicking it does not trigger any action. Here's my code; however, I'm unsure why the button in the Navbar isn't functioning as intended. ...

Using PHP and jQuery, you can create an onclick event that triggers a form

I'm having some trouble getting this code to function properly: <?php if(isset($_POST['submit'])){ echo "<script>location='https://google.com'</script>"; exit(); } ?> <html> <head> <script> ...

Generate time-dependent animations using circles

Hey there, I am trying to create an animation that involves drawing three circles and having one of them move from right to left. The circles should appear randomly in yellow, blue, or orange colors on the canvas at different intervals (3 seconds between ...

Is it possible to navigate between jQuery EditInPlace fields using the Tab key?

Seeking advice on implementing tab functionality for a page with multiple jquery EditInPlace fields. The goal is to allow users to navigate between fields by pressing the tab key. Currently using the 'jquery-in-place-editor' plugin available at: ...

JavaScript - Attempting to insert a value into a text field by clicking a button

I am struggling to get my function to properly add the value of the button to the text field when clicked by the user. HTML <form name="testing" action="test.php" method="get">Chords: <textarea name="field"& ...