Window enhancement using box-shadows for opening and closing

While playing with box-shadows, I had an idea to create a window effect where you can hide text or an image underneath and reveal it when hovering or clicking (like the example below).

Unfortunately, my initial attempt didn't work as planned because the shadow always stayed below the content, something I realized only after finishing.

Is there a way to fix this issue with box-shadows, or should I explore alternative methods to achieve the same outcome?

body {
background: #20262E;
}

.window {
display: inline-block;
height: 200px;
width: 300px;
margin: 20px;
background: #F8F8F8;
text-align: center;
line-height: 200px;
}

.window {
box-shadow: inset 0 200px #0084FF;
transition: box-shadow 1s ease-in-out;
}

.window:hover {
box-shadow: inset 0 0 #0084FF;
}
<div class="window">
  box 1
</div>

*Note: The transition flickering issue is still puzzling me :/

Answer №1

It seems likely that there is a bug with the box-shadow. If you are interested in exploring an alternative CSS solution, have you considered utilizing the :before or :after pseudo elements?

body {
  background: #20262E;
}

.window {
  display: inline-block;
  height: 200px;
  width: 300px;
  margin: 20px;
  background: #F8F8F8;
  text-align: center;
  line-height: 200px;
  position: relative;
}

.window:after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: #0084FF;
  transition: bottom 1s ease-in-out;
}

.window:hover:after {
  bottom: 100%;
}
<div class="window">box 1</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

Risk Score Generating Form

As I work on a comprehensive form, there are 5 sections for users to mark if they qualify (using checkmarks). The form consists of approximately 50 questions in total. Each section carries different weights/points (e.g., Section 1 is worth 1 point each, ...

What is the most effective method for managing versions of CSS, JS, font icons, and images?

Managing multiple CSS files, shared properties, JS files, font icons, and images that require constant updates can be exhausting. Every time I try to push changes to the main repository, I have to bump the version number of each file using "?=number", whic ...

Flex containers positioned next to each other without overlapping and adjusting in relation to one another

I would like to prevent the lower div (which includes an image and a button) from overlapping with the division above it that contains text. So, when the button encounters this upper division, I want it to move down in a way that pushes the image beneath i ...

What is the best way to toggle the visibility of a background image within a carousel?

As a beginner in j-query, I am struggling with creating a slider image carousel using a full background image. Most of the solutions I found online require a fixed width for all pictures to slide smoothly. However, I believe there might be a way to use an ...

Steps for modifying the [disabled] attribute of an Angular element

I need to update the [disabled] property of the "app-box-ceding-company-definition" object; in the TypeScript file, the property is initially set to true but I want to change its value based on a condition. Condition: if selectrow.status == "01" => dis ...

Customizing the appearance of Indicators and Paginator in PrimeNG Carousel

I have integrated a carousel using PrimeNG which has the following design here Take note of the style of the carousel indicators and navigators. I want to achieve the default style of indicators/navigators for the carousel as shown here I have included t ...

Building a theme with TypeScript in React

As I embark on my React project, I've been tasked with creating a CSS using TypeScript while referring to the color palette diagram provided below. Utilizing createMuiTheme to build the theme, I've realized that there are various possible conditi ...

What is the best way to create an arrow that tracks the browser window, but only goes as far as the end of its designated container

Currently, I am facing a challenge in implementing a scroll down arrow. While this is typically a simple task, it has proven to be a bit more complex this time around. The complexity arises from the fact that my customer desires a homepage with an image of ...

Create a vertical expand/collapse menu using Javascript that persists its state even after a page change

As I embark on the journey of constructing my webshop, please forgive any imperfections you may stumble upon, unless they pertain to the subject at hand. Currently, I am in the process of crafting the shop menu, utilizing a vertical collapse/expand menu b ...

What is the method to make a String bold when sending it through a messaging service?

Here is the structure of my service: import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root', }) export class MessageService { messages: string[] = []; add(message: string) { this.messages.push(message); ...

Is there an easy method for customizing scrollbars?

I'm looking to include an "overflow:scroll" in a navigation div, but the default scrollbar on windows is unattractive. Is there a simple way to customize the scrollbar without having to download extra JavaScript libraries, APIs, and so on? ...

Copying text from an iframe using HTML and JavaScript

As someone who is relatively new to web development, I am currently attempting to transfer text from an iframe to a textarea located on a Bootstrap-html webpage. You can view an example of the code I am working with here: https://jsfiddle.net/fe5ahoyw/ J ...

Stop input elements from receiving focus when the dialog is displayed on the webpage

I successfully integrated a dialog in my html code. My current goal is to: Within my dialog, there is a form with various form elements. Additionally, there is another form on the main page located underneath the dialog. Currently, when I press the tab ...

Error occurred while fetching image from Medium story API in Next.js

While working on my Next.js app, I encountered an issue with the Medium story API. Every time I try to fetch and display an image using the API, I receive an error message stating "upstream image response failed." The specific error code is: upstream image ...

Elements floating in space, stretching across the entire width

In my design, I have a fixed size layout with a centered content container. My goal is to have the menu (home, about, contact, login) span 100% of the screen width. You can view the current setup in this jsfiddle: http://jsfiddle.net/Hxhc5/1/ I am aimin ...

What could be the reason why the border of my table displays in Firefox and Chrome, but remains hidden in Internet Explorer

I am facing an issue with getting a border to display on a table in Internet Explorer versions IE6, IE7, and IE8. The border is showing up fine in Chrome and Firefox but not in the mentioned IE versions. Below is the CSS code that I have been using: #info ...

Centralizing JavaScript Background Video

How can I make my video centered on any screen size? I have the CSS in place to ensure that the video always covers the screen proportionally, but I need help with centering it at all times. HTML <div class="heroWrapper"> <video autoplay muted ...

Automatically queue up and play videos seamlessly back-to-back on iOS without needing any user

I am faced with a challenge of playing a sequence of HTML5 videos one after another when each video ends. The initial action is triggered by the user clicking on a "play" button on the first video, with subsequent videos following automatically. While my ...

Achieve a straightened appearance for background images within a skewed container

Can I un-skew the content inside a skewed carousel, while preserving the diagonal effect on the slide container? Check out the Jsfiddle example here - https://jsfiddle.net/czcjt3no/1/ <div class="section"> <div class="grid poly--holder"> ...

Table design variation for desktop and mobile display

I'm new to this location and could really use some assistance. I'm trying to create a page that can be viewed on both desktop and mobile devices, featuring a table. On desktop, the table displays as follows: th1 th2 th3 td1-1 ...