Achieving a half-faded effect for an image using CSS

https://i.sstatic.net/4SMsM.jpg

In the image provided, there is a need to smoothly fade half of it without relying on opacity for the effect. The current method does not achieve the desired smooth fading effect.

Answer №1

This approach offers a straightforward solution:

html,body{
  padding:0;
  margin:0;
  width:100%;
  height:100%;
  background-image: url("https://www.itl.cat/pngfile/big/76-763664_cute-child-in-a-flower-field-4k.jpg");
  background-size:cover;
  background-repeat:no-repeat;
  background-position:center;
}
div{
background: rgba(255,255,255,0.9);
background: -moz-linear-gradient(left, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.9) 15%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.9) 85%, rgba(255,255,255,0.9) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(255,255,255,0.9)), color-stop(15%, rgba(255,255,255,0.9)), color-stop(50%, rgba(255,255,255,0)), color-stop(85%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0.9)));
background: -webkit-linear-gradient(left, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.9) 15%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.9) 85%, rgba(255,255,255,0.9) 100%);
background: -o-linear-gradient(left, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.9) 15%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.9) 85%, rgba(255,255,255,0.9) 100%);
background: -ms-linear-gradient(left, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.9) 15%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.9) 85%, rgba(255,255,255,0.9) 100%);
background: linear-gradient(to right, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.9) 15%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.9) 85%, rgba(255,255,255,0.9) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff', GradientType=1 );
width:100%;
height:100%;
}
<div>
&nbsp;
</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

Increasing a local variable in the view using ASP.NET

Despite its seeming simplicity, I'm struggling to find the solution to this problem. When adding a number (like 2) to a page variable, it's being recognized as a string and displaying: instead of 3 : 1+2 @{ var page= 1 ; } <li>@ ...

I aim to adjust the width of a logo and ensure its size is fixed for optimal visibility

The selected logo needs to be more visible. I have attempted to use media queries to adjust its visibility, but I am having trouble with it. I want the logo to be able to stretch in width, but I am unsure how to achieve that. Currently, this is what I hav ...

Making a floating action button in Ionic

I am currently working on creating an action floating button using the Ionic framework. While I have successfully created a basic button, I am now looking to add some stylish effects and make additional buttons appear upon interaction. I understand that th ...

Enhance the appearance of Font Awesome stars by incorporating a hover effect

Is there a straightforward way to make them turn solid yellow when you hover over them? const styles = theme => ({ root: { flexGrow: 1, overflow: 'hidden', padding: theme.spacing(0, 3), }, paper: { maxWidth: 800, mar ...

Divide a single image into several smaller images and enable clickable links on each separate image, similar to an interactive image map

Challenge: I am faced with the task of splitting a large image (1920px x 1080px) into smaller 40px by 40px images to be displayed on a webpage. These smaller images should come together seamlessly to recreate the original full-size image, with 48 images a ...

Verify if spacebar is pressed and then use jQuery to add a hashtag with multi-language support

I am attempting to use jQuery to add a hashtag (#) after the user types and presses space. I have created a demonstration on CodePen. In this demo, when you type something like (how are you), the JavaScript code will change it to (#how #are #you). To ach ...

Show information stored in Angularjs2 file (.ts) within an HTML document

Here is the code snippet from my .ts file: constructor( private config : ConfigService, private http: Http){ this.getWS('ngoName') .do((data) => { console.log(data); this.saveObj(data); }).to ...

Utilize PHP to select the same checkbox across multiple pages of a form through a post request

I am a newcomer to coding and I am trying to figure out how to automatically select the same check-box that was marked on the first page of my multi-page form. For example, if the user checks the box labeled Red, I want the box on page 2 to be auto-filled ...

angular js validation is not working properly

Currently, I am working on a basic HTML page that requires validation using AngularJS. I imported the HTML file with AngularJS in the following manner: <title>Student Registration Form</title> <script src="https://ajax.googleapis.co ...

Uncovering the jsPlumb link between a pair of identifiers

Could someone help me understand how to disconnect two HTML elements that are connected? I have the IDs of both elements, but I'm not sure how to locate their connection in the jsPlumb instance. Any tips on finding the connection between two IDs? ...

How to keep an iFrame refreshed with top.window?

It's interesting how refreshing top.window with a frame reloads the iframe, but not with an iframe itself. The use of frames is now deprecated, so should we still utilize them? Unfortunately not. Does this mean losing functionality if I choose to fol ...

What is the best way to add two popups to a marker in Leaflet? One triggered by mouseover and another by a click event?

Is there a way to make a title hover over my map markers, but then have a full popup with unique content open up when they are clicked? I attempted to create a legend with a list of markers as links for popups, but I couldn't figure out how to do it. ...

Creating an image that scales to full width within a Bootstrap column after switching to mobile view

I am having trouble getting the image on the right to expand to full width when the screen size is reduced, transitioning it to mobile view. Is there a Bootstrap class that works similarly to "img-fluid", but displays the image in full width below the text ...

What is the best way to expand the Bootstrap container's width to the maximum size?

I'm having an issue with implementing a DataTable within a Bootstrap container. When viewing the website at maximum width, the table container adds a scrollbar and cuts off the last column in the table. Attempted solutions such as using a `container- ...

Jquery Timer that can be toggled on and off with a single button

I'm really struggling to find a way to make this work smoothly without any bugs. The button in the code below is supposed to perform three actions: Initiate a countdown when clicked (working) Stop the countdown automatically and reset itself when it ...

When using NVDA, the close button is being read multiple times, whereas in JAWS it is being read correctly

Here is the code for a close button within a modal pop-up: <h2 class="sc-ejdXBC byjYiM MuiTypography-root MuiTypography-h6 sc-EoWXQ kOYWJk MuiDialogTitle-root" id="popupTitle"> Default Pop-UP Title <button class="sc-dm ...

What is the best way to determine the width of the browser in JavaScript?

I'm attempting to create a JavaScript function that retrieves the current browser width. After searching, I came across this method: console.log(document.body.offsetWidth); However, it doesn't work well if the body width is set to 100%. Are ...

Letters are frolicking in varying sizes and designs

Currently, I am encountering a strange issue with the text on my webpage. Some fonts are displaying with completely different shapes and sizes despite using <meta charset="UTF-8"> to ensure font consistency. Unfortunately, this did not resolve the pr ...

Update the style class of an <img> element using AJAX

My success with AJAX enables PHP execution upon image click. However, I seek a real-time visual representation without page reload. Thus, I aim to alter <img> tag classes on click. Presently, my image tag resembles something like <img title="< ...

Determine whether a WebElement contains a particular content within the :after pseudo class

After locating my element in Selenium, I've come across an interesting challenge. IWebElement icon = box.FindElement(By.ClassName("box-icon")); Sometimes, this element (icon) has a content set as follows: &:after { content: $icon-specia ...