{"id":1691,"date":"2025-03-04T17:30:39","date_gmt":"2025-03-04T17:30:39","guid":{"rendered":"https:\/\/codebox.keyframetechsolution.com\/?p=1691"},"modified":"2025-03-30T06:18:38","modified_gmt":"2025-03-30T06:18:38","slug":"curtain-scroll-effect-html-css-js","status":"publish","type":"post","link":"https:\/\/codebox.keyframetechsolution.com\/curtain-scroll-effect-html-css-js\/","title":{"rendered":"How to Make Curtain Scroll Effect using HTML CSS and JavaScript"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><span data-preserver-spaces=\"true\">A curtain scroll effect is a visually appealing animation commonly used on websites to reveal content in a dramatic and engaging way. This effect simulates the opening and closing of curtains, allowing users to focus on the content behind them. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">In this tutorial, we will guide you through creating a stylish curtain scroll effect using HTML, CSS, and JavaScript, which reveals content as the user scrolls down the page. This effect can be applied to various types of content, including images, text, and videos.<\/span><\/p>\n<p>\u2705\u00a0<strong>Watch Live Preview<\/strong>\u00a0\ud83d\udc49\ud83d\udc49<\/p>\n<p><iframe title=\"Curtain Scroll Effect | HTML CSS &amp; JavaScript #youtubeshorts\" src=\"https:\/\/www.youtube.com\/embed\/jPTUSMMIXlg\" width=\"100%\" height=\"450\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><a href=\"#conclusion\">Click Here to Download the Code<\/a><\/p>\n<h2><span data-preserver-spaces=\"true\">What are the Steps to Create?<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">First, make a folder on your computer and add the following files inside it:<\/span><\/p>\n<ul>\n<li><span data-preserver-spaces=\"true\">index.html<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">style.css<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">script.js<\/span><\/li>\n<\/ul>\n<p><strong>Read also:<\/strong> <a href=\"https:\/\/codebox.keyframetechsolution.com\/on-scroll-animation\/\">Create On Scroll Animation using HTML CSS and JavaScript<\/a><\/p>\n<h2><span data-preserver-spaces=\"true\">Source Code<\/span><\/h2>\n<h3><span data-preserver-spaces=\"true\">HTML Code<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">The first step in creating the curtain scroll effect is setting up your HTML structure. This involves defining the elements that will serve as the curtains and the content to be revealed behind them.<\/span><\/p>\n<p><strong>Here\u2019s the code:<\/strong><\/p>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">index.html<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=\"UTF-8\"&gt;\r\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n  &lt;title&gt;Curtain Scroll Effect using HTML CSS and JavaScript&lt;\/title&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/4.7.0\/css\/font-awesome.min.css\"&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/fonts.googleapis.com\/css2?family=Poppins:wght@400;500;600;700&amp;family=Ubuntu:wght@400;500;700&amp;display=swap\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- CODE --&gt;\r\n\r\n&lt;script src=\"script.js\"&gt;&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3><span data-preserver-spaces=\"true\">CSS Code<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">Now let\u2019s move on to the CSS part, where we\u2019ll create the visual structure for the curtains and style the content. The curtains will initially be positioned to cover the entire screen, and as the user scrolls, they will reveal the content.<\/span><\/p>\n<p><strong>Here&#8217;s the code:<\/strong><\/p>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">style.css<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/* Your CSS code here *\/ &gt;\r\n&lt; * { &gt;\r\n\r\n&lt; margin: 0; &gt;\r\n&lt; padding: 0 &gt;\r\n&lt; box-sizing: border-box; &gt;\r\n&lt;     text-decoration: none; &gt;\r\n&lt;     } &gt;\r\n      <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3><span data-preserver-spaces=\"true\">JavaScript Code<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">Now that we have the HTML and CSS set up, it\u2019s time to add some JavaScript to trigger the <a href=\"https:\/\/codepen.io\/Afarah92\/pen\/oNzYzWB\" rel=\"nofollow noopener\" target=\"_blank\">curtain scroll effect<\/a> when the user scrolls down the page. This will involve detecting the scroll event and animating the curtains to reveal the content.<\/span><\/p>\n<p><strong>Here\u2019s the code:<\/strong><\/p>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">script.js<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/\/ JavaScript Code &gt;\r\n      <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3><span data-preserver-spaces=\"true\">Test the Effect<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">Once you\u2019ve set up the files, open your project in a browser and scroll down to see the curtain effect in action. Initially, the curtains will cover the content. As you scroll, they will smoothly slide to the sides, revealing the content behind them.<\/span><\/p>\n<h3><span data-preserver-spaces=\"true\">Optional Enhancements<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">Here are some ideas to enhance this curtain scroll effect:<\/span><\/p>\n<ol>\n<li><span data-preserver-spaces=\"true\"><strong>Dynamic Speed:<\/strong> You can adjust the speed of the curtain animation based on how far the user has scrolled. For example, you can make the curtains open faster as the scroll position increases.<\/span><\/li>\n<li><span data-preserver-spaces=\"true\"><strong>Opacity Transition:<\/strong> Instead of just sliding the curtains, you can also adjust their opacity to fade them in and out as they move.<\/span><\/li>\n<li><span data-preserver-spaces=\"true\"><strong>Curtain Color or Pattern:<\/strong> Add a background image or gradient to the curtains for a more aesthetic look.<\/span><\/li>\n<li><span data-preserver-spaces=\"true\"><strong>Responsive Design:<\/strong> Ensure the effect works on all screen sizes by tweaking the CSS and JavaScript accordingly.<\/span><\/li>\n<\/ol>\n<p><strong>Read also: <\/strong><a href=\"https:\/\/codebox.keyframetechsolution.com\/scroll-animations-on-website-with-gsap-scrolltrigger\/\">Create a Website with Scroll Animations Using GSAP ScrollTrigger<\/a><\/p>\n<h2 id=\"conclusion\"><span data-preserver-spaces=\"true\">Conclusion<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">It is a visually appealing technique that adds an engaging touch to your website by creating a smooth, interactive animation that draws users&#8217; attention to the content behind the curtain.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">By learning and applying these techniques, you can incorporate more dynamic and creative elements into your web projects. Whether you&#8217;re showcasing a portfolio, promoting a product, or simply looking to add a unique flair to your design, the curtain scroll effect is an excellent tool <\/span><span data-preserver-spaces=\"true\">to have<\/span><span data-preserver-spaces=\"true\"> in your web design toolkit.<\/span><\/p>\n<p><strong><i class=\"fa fa-download\" style=\"color: #046bd2;\"><\/i> 14 people bought this<\/strong><\/p>\n<p>Hurry, Get it Now for Only <i class=\"fa fa-rupee\" style=\"color: #046bd2;\"><\/i><span style=\"color: #046bd2;\">30<\/span> <del>\u20b950<\/del><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction A curtain scroll effect is a visually appealing animation commonly used on websites to reveal content in a dramatic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1693,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[88],"tags":[491,493,489,490,492],"class_list":["post-1691","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-designs","tag-curtain-animation-css","tag-curtain-opening-animation-html","tag-curtain-scroll-effect","tag-curtain-scroll-effect-css","tag-curtain-scroll-effect-javascript"],"acf":[],"_links":{"self":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/comments?post=1691"}],"version-history":[{"count":4,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1691\/revisions"}],"predecessor-version":[{"id":1878,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1691\/revisions\/1878"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media\/1693"}],"wp:attachment":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media?parent=1691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/categories?post=1691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/tags?post=1691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}