Make the div stretch to the entire page size while keeping the existing content intact

I have a concept in mind where I want a clickable circle on the top left corner that expands to full page when clicked. Using a scale, I was able to achieve this effect.

.hover.opened {
    transform: scale(1);
    transition: all 0.5s ease-out;
    overflow: hidden;
}

View example here

Now, my goal is to have the red circle's content already in place (without scaling) but not visible, and have the red circle expand to reveal the content. To better illustrate this idea, please see this image: https://i.sstatic.net/5HQd3.png The content remains at the correct scale and becomes visible only as the red circle grows.

How can this be achieved? Is it even possible? Your insights are appreciated. Thank you.

Answer №1

My approach differs slightly from yours.

HTML:

<div class="top-circle">
    <div class="inner-text">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </div>
</div>

CSS:

html, body{
    background:#555;
    padding:0;
    margin:0;
    overflow:hidden;
    width:100%;
    height:100%;
}
.top-circle{
    top:0;
    left:0
    position:absolute;
    width:50px;
    height:50px;
    background:red;
    overflow:hidden;
    border-radius: 0 0 5000px 0;
    transition:all 0.7s ease-out;
}
.inner-text{
    margin: 50px;
    width:500px;
}

jQuery:

$(function(){

    $('.top-circle').click(function(){
        $(this).width($(window).width()+500);
        $(this).height($(window).height()+500);
    });
});

Here is the link to jsFiddle.

Answer №2

If you dabble a bit in CSS3, you have the option to take a different approach. Consider it as crafting a mask that uncovers a set content beneath.

So instead of applying the red color to the parent div responsible for drawing the circle, you can apply it to the background of the nested div.

Take a look at this modified example based on your code utilizing clip-path:

.youtube {
    -webkit-transition: scale(1);
    transition: scale(1);
    -webkit-transition: all 0.5s ease-out;
    transition: all 0.5s ease-out;
    -webkit-clip-path: circle(50px at left top);
    clip-path: circle(50px at left top);
    height: 100%;
}
.youtube.opened {
    -webkit-clip-path: circle(100% at center);
    clip-path: circle(100% at center);
}
.hover-content {
    background-color: red;
    width: 100%;
    height: 100%;
}

View an interactive demo here: http://jsfiddle.net/1cgonza/trn8oy8o/

Currently, this may not be the most compatible solution across all browsers, but it serves as a starting point. Using SVG images as clip-path tends to yield better results. Explore this and further references provided in these resources: https://css-tricks.com/almanac/properties/c/clip/

Answer №3

Are you looking for something similar to this?

Check out the Fiddle

.hover.opened {
transform: scale(1);
transition: all 0.5s ease-out;
overflow: hidden;
font-size:50px;
transform: scale(0.50);

}

View Updated fiddle here

Answer №4

Are you pleased with this outcome?

var youtubePanel = document.querySelector(".youtube");

youtubePanel.addEventListener("click", function() {
youtubePanel.classList.add("opened");
});
@import url(https://fonts.googleapis.com/css?family=Roboto);

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body, html {
width: 100%;
height: 100%;
font-family: 'Roboto', sans-serif;
color: #BBB;
}

body {
background-color: #3D4045;
position: relative;
overflow: hidden;
}

.hover {
position: absolute;
overflow: hidden;
}

.hover.hover-top-left {
top: -1000px;
left: -1000px;
width: 2000px;
height: 2000px;
}

.hover-content {
position: relative;
    top: 66%;
    left: 69%;
    transform: scale(20);
    opacity: 0;
    font-size: 65px;
    width: 900px;
}

.youtube {
background-color: #CC181E;
border-radius: 100%;
transform: scale(0.05);
}

.hover.opened {
transform: scale(0.25);
transition: all 0.5s ease-out;
overflow: hidden;
}

.hover.opened>.hover-content {
transform:scale(1);
transition: opacity 0.5s ease-out;
opacity: 1;
}
<div class="hover hover-top-left youtube">
    <div class="hover-content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</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

Restrict the dimensions of the HTML5 Facebook comment field

I need help limiting the vertical height of Facebook comments generated by the code below. I know how to set the width using the data-width parameter, but I'm not sure how to limit the vertical height of the comment box. Can anyone provide guidance on ...

Searching for a specific text within a column and displaying only the matching parts

My current dataframe has the following structure: RandomCol raw blah <div style="line-height:174%;text-align:left;font-size:9pt;"><font style="font-family:inherit;font-size:9pt;font-style:italic;font-weight:bold;">We ...

Learning how to replace the alert function with Bootbox

I am currently working on a form that posts to a MySQL database. I want to replace the alert function triggered by the Malsup jQuery Form Plugin with the one created by the Bootbox plugin. Even though both plugins are functional, I struggle to integrate th ...

What is the best way to restrict the border to just one element?

I've configured my navigation bar using a list with li elements. To give it a rounded appearance, I applied a border-radius to the background. Now, I'm looking to remove the border-left specifically from the home element. Below are the code snipp ...

Implementing a document click event to reset timeouts using JQuery

I'm having trouble resetting a timeout timer every time there is a click interaction with the document. The clearTimeout function doesn't seem to be working as expected. Here is the jQuery code snippet: $(document).click(function(e){ $("#vidB ...

Adjusting the header background color and inserting a logo once a specific threshold is reached

Currently, I am designing a website where I need the background color to transition from transparent to black and display a logo once the user scrolls down to a certain point. I am a beginner in javascript and I am facing some difficulties with this task. ...

Load images in advance for hover effects on active selectors within the specified CSS file paths

Currently, I have opted not to utilize css sprites. While I acknowledge that it is the most efficient solution, time constraints prevent me from implementing it at this moment. I am seeking a method to preload all images for hover and active selectors. ...

Top strategy for incorporating/displaying extra form fields

Seeking advice on improving user interface design. I want to develop a form that enables users to add more fields by clicking on a "+" or "add" button. For instance, the user can fill out a text field labeled as "Description," followed by another field n ...

Attempting to incorporate a hover effect into this piece of JavaScript code

Hello, I've been trying to implement a mouse-over effect into this code but have not had much luck. Any assistance would be greatly appreciated. If you require additional information, please let me know. The issue I am facing is that when I hover ove ...

JavaScript in Internet Explorer is showing an error message stating that it is unable to access the property '0' of an undefined or null

JavaScript Code function update() { var newAmt = 0; var newtable = document.getElementById("tbl"); for ( var i = 0; i < newtable.rows.length; i++) { innerTable = newtable.rows[i].cells[0].childNodes[0]; if ( (innerT ...

The conditions specified in my JavaScript if statement are seemingly being disregarded, even after I forcefully alter the variable at the conclusion of the function

var app = angular.module("calculatorApp", []); app.controller("CalculatorCtrl", CalculatorCtrl); function CalculatorCtrl() { pleaseWork = null; this.buttonClicked = function(button) { if (pleaseWork = null) { this.seco ...

The issue with line-height causing the sliding URL effect to malfunction

Having a sliding underline URL effect (viewable here: http://codepen.io/Dingerzat/pen/XNgKmR), I encountered an issue when combining it with a resizing header. The resizing header caused the sliding underline effect to stop working. After some troubleshoot ...

Trying to retrieve a CSS property using jQuery

Having trouble retrieving the correct CSS value for a background using a spectrum.js color picker. No matter which color is chosen, rgba(0,0,0,0) is always selected. Strangely enough, when checking the background in the console, it shows up correctly in th ...

Retrieve the CSV file following a successful POST request

Is there a way to automatically download a CSV file upon clicking a button that triggers a post request? The post request generates a large response, making it inefficient to transfer it directly from express to the front end. I'm looking for a solu ...

Utilizing a Variable in an AngularJS <div> Tag

My controller, named "HomeCtrl", is responsible for calculating the total number of users and storing it in the {{total}} binding variable. Here is the code snippet: .controller('HomeCtrl', function($scope, $http){ $scope.total = 0; }); Wit ...

What causes the payload to display [object File] when files are being uploaded?

I am having an issue with posting a file to an API. The file is displayed correctly in the console, but when uploaded to the API, it shows as [object file]. Below is the function for handling the file: handleFileChange = (e) => { const files = e.target ...

"Eliminate specific time increments like days, hours, and minutes when the timer reaches zero in a jQuery countdown

Utilizing jQuery countdown, I am attempting to eliminate days/hours/minutes when the timer reaches 00 using the update callback function .on('update.countdown', function(event) {. It is almost working correctly. However, there is just one issue: ...

ASP.NET jQuery .load method failing to invoke controller action

I'm currently working on a project that involves displaying a list in a partial view using AJAX and JQuery with Entity Framework. The goal is to allow the user to click on an action link in the navbar, triggering a JQuery event that fetches a list fro ...

The CSS method will not function properly on Safari when targeting the specific ID

that.displayIcon = that.scrollPosition / that.headerHeight $('#icon').css({'opacity':that.displayIcon}) that.rotateIcon = Math.min(1,that.scrollPosition/that.headerHeight) $('#icon').css({'transform':'rot ...

The model.find operation is failing to retrieve the necessary fields from the database

When I execute console.log(correct.password), it returns undefined, even though the if condition results in false. app.post('/login' , async (req , res)=> { const correct = data.findOne({name : req.body.name}).select({name : 0}); if(!c ...