What is the best way to limit, clip, or mask an object using HTML and CSS?

This is my HTML:

http://jsfiddle.net/aALJ6/ (you may use this for reference)

<article>
<a href="http://www.somepage.com">
    <header>
        <div class="details">   
            <h1>Title</h1>
            <p>More text</p>
        </div>
    </header>
    <span class="bw-wrap"><img src="http://lorempixel.com/353/324/sports/" alt="NASA Space Apps Challenge" class="bw" /></span>
    <span class="clr-wrap"><img src="http://lorempixel.com/353/324/sports/" alt="NASA Space Apps Challenge" class="clr" /></span>
</a>
</article>

Here is the accompanying CSS:

article {
    background:#d0d0d0;
    border:1px solid #b9b9b9;
    border-radius:150px;
    float:left;
    margin:0 0 30px 30px;
    overflow:hidden;
    padding:9px;
    position:relative;
    transition:all 0.2s ease-in;
    -webkit-transition:all 0.1s ease-in;
    -moz-transition:all 0.1s ease-in;
    -o-transition:all 0.1s ease-in;
    width:280px;
    height:280px
}
img {
    border-radius:140px;
    position:absolute;
    top:9px;
    left:9px;
    overflow: hidden;
}
.clr {
    opacity:0;
    z-index:1;
    transition:all 0.2s ease-in;
    -webkit-transition:all 0.2s ease-in;
    -moz-transition:all 0.2s ease-in;
    -o-transition:all 0.2s ease-in
}
article:hover.clr {
    opacity:1
}
.portfolio-single {
    float:left;
    padding-bottom:30px;
    position:relative;
    width:100%
}
article:hover {
    background:#272123;
    border:1px solid #272123
}
h1 {
    position: absolute;
    left: 65px;
    top: -20px;
    z-index:100;
    text-align:center;
}
p {
    position: absolute;
    left: 95px;
    top: 30px;
    z-index:100;
    text-align:center;
}

The issue at hand lies in containing the dark rectangle within the circular article/img element during the opacity animation. While normal clipping works fine, the full rectangle is displayed only when the opacity reaches 100%, disrupting the desired look.

Answer №1

Success!

HTML:

<img class="logo-mask" src="Text2.svg" />

CSS:

.logo-mask {
opacity:0; 
position:absolute;
-webkit-mask-image: url("TextMask2.svg");
}

This method works like a charm. Unfortunately, Dreamweaver doesn't seem to recognize it, but browsers do! Much appreciation for your help!!!

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

Ensure the content is optimized for all screen sizes, utilizing Bootstrap to adapt accordingly

I have a webpage with a header, a footer, and a container id="item" that contains a list of four items with their respective logos. I am attempting to make the item container responsive based on the screen size so the entire page fits the screen without re ...

Is there a grid system built with Sass, Less, or other similar tools?

In the past, I have relied on 960.gs for grid layouts in my designs and found it to be very effective. However, I've always been bothered by the excessive amount of classes in the HTML code. As a web purist, styling within the markup has never felt qu ...

Alter the tab's color upon clicking the button

I am working on a multi-step form and I wanted to enhance the user experience by adding a button at the bottom of the page for easy navigation instead of relying on tabs at the top. Although the button functions as intended, there is an issue with the tab ...

Applying the transform:scale property to the parent element causes the child element's dropdown menu to appear beneath a different row

When attempting to scale my row on hover, I encounter an issue with my dropdown menu. If the dropdown menu is open, it gets hidden under the next row. How can I ensure that it stays on top? I have tried using z-index, but it doesn't seem to help. The ...

Tips for inserting text onto an image using a hover effect

I have designed a section on my website where an image darkens upon hovering, and I would like text to appear centered both horizontally and vertically when the image is hovered over. However, despite my efforts, the text does not display on the image as i ...

CSS Malfunction in Chrome: Some Code Not Displaying Properly

Below is the content of my main.css file: body { font-family: josefin; } .splash-content { text-align: center; } .register-button { color: #6A136C; width: 300px; height: 100px; border: 5px solid #6A136C; } .btn { padding: 1 ...

Guide on incorporating a Bootstrap date time picker in an MVC view

Is there a live example available that demonstrates how to implement the latest Bootstrap date time picker in an MVC view? In my project, I have already included: - jQuery. - Bootstrap JS. - Bootstrap CSS. ...

When you open the link in a new tab, the form submission does not occur

I am currently working on a form that includes a JavaScript submit function. Within the form, there are 3 anchor tags that I want to use to set different values to a hidden parameter when submitted based on the link clicked. Although the form submission w ...

Tips on pausing a moving image from left to right and restarting it later

Is there a way to pause the left to right moving image at the end and then restart the loop? I tried utilizing this website link for assistance: https://www.w3schools.com/cssref/tryit.asp?filename=trycss3_animation-delay Unfortunately, I couldn't fi ...

Elements with absolute positioning become distorted when the browser is resized

As I work on creating dropdown menus for my website, I noticed that they appear very nice and organized on laptop screens with a resolution of 1280 x 800. However, when these menus are scaled to larger sizes, they tend to separate from each other even thou ...

What is the best way to center-align elements?

I have a couple of inquiries. First off, I'm facing an issue with centering everything within a form while aligning the text to the left side of the fields. I've attempted using justify-center and align-items within the "container" class and th ...

Contrasting hierarchy of text-decoration and text-shadow in Firefox compared to Chrome

When viewing this HTML/CSS code in Firefox and Chrome, the text-decoration and text-shadow properties appear to be swapped between browsers. .foo { font-size:2em; text-decoration:underline LightBlue 1ex; text-decoration-skip-ink:none; ...

A large responsive bootstrap website filling only half the screen

I am currently in the process of developing a simple version of a Content Management System (CMS). I have created a page that offers an HTML template, allowing users to insert their own text and image uploads to display on another screen. The template fun ...

Background image in Bootstrap not covering entire web page

I am facing an issue where the background image is confined within the constraints of the login panel, and I'm unsure why. My goal is for the image to span the full width and height of the browser window. Any assistance on this matter would be greatly ...

Apply a static style to every rendered component just one time

Is there a way for me to individually style each card image only once? For example, I want to apply a transform style via a function in CSS; I want the image to maintain its original value, but when a new component is rendered, that card should have a di ...

Displaying a Key/Value pair as a clickable link using AngularJS

Having difficulty generating links from KeyValue pairs in an object using AngularJS. The object is created in C# with the code snippet below: Dictionary<int, string> page = new Dictionary<int, string>(); updatedCountryNodesLis ...

Display the total count of textboxes only once following the entry of a new value into the textbox

<html> <title> </title> <head> <link rel="stylesheet" href="new_2.css" type="text/css"/> <script src="jquery-1.10.2.min.js"></script> <script> function GeneratingTextFields() { var NumberOfText = $("#Num ...

The event is not functioning properly with jquery

<div id="form"> <form action=""> <input type="button" id="sub"/> </form> </div> Upon clicking the submit button, the content will be dynamically changed using jQuery. Here is the jQuery code: $(document).ready(function() { ...

Guidelines on transforming XML files into HTML tables using C++ programming language

Is there a C++ library available that can help me convert an XML file into an HTML table using my C++ application? For example: <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <d ...

Trimming Text with JQuery

My goal was to truncate a string and add an ellipsis at the end using jQuery, but my code doesn't seem to be working as intended. Below is the jQuery code I wrote: $(".link-content > h4").each(function(){ var len = $(this).text().length; ...