On a lot of websites, you must have seen a Top button while you scroll to the bottom. That is called the “scroll back to top” button. Create a Button First, create a button that will be clicked to reach the top − Top Style the top Button The display is set to none to make the button hidden. The button is positioned fixed using the fixed value of the position property. The bottom property is used to position the button downwardsn − topBtn { display: none; position: fixed; bottom: 20px; right: 30px; z-index: 1; ... Read More
To create a fixed menu on a web page, use the position property and set the value fixed. Set the width to 100% using the width property. Set the Navigation Menu Use the element to create the navigation menu on a web page. The links are set using the and the href attribute − Home Login Register Contact Us More Info Style the Navigation Menu We have positioned the menu as fixed using the position property with the value ... Read More
We will see how to create a coupon with CSS. For that, we need to set the company name on the top, an image below, After that comes with coupon code and a text representing when the coupon will expire. Set the Parent Container for the Coupon We gave set the parent cdiv here. Within this we will set the divs for the text, image, etc − Style the parent container − .couponContainer { border: 5px dashed #bbb; width: 80%; border-radius: 15px; margin: 0 auto; max-width: 600px; } Set the Container for the ... Read More
We will create a coming soon page with a timer. The timer is set using the setInterval() function. The time is fetched using the getTime() function. Set the div We have set the image as a div class. Rest, the coming soon text and the timer is placed within it − COMING SOON Place the Image The image is now placed using the background-image property. The position is set using the background-position property” .bgimg { background-image: url("https://images.pexels.com/photos/117602/pexels-photo-117602.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"); height: ... Read More
On a web page, we can easily create a card like you must have seen on a Team’s page. The employee name, and designation is visible with a thumbnail image. With CSS, we can easily a card and also set the hover style using the :hover selector. Set the Card Image The element is used to set the image for the card. Place it inside a div − Amit Diwan Founder ... Read More
On a web page, we can easily create a button group. We will create a single div for all the buttons in a button group. They will be set with display inline-block. Also, the hover effect will be set. Create a Button Group on a web Page In a div, set the buttons using the element − Facebook Twitter LinkedIn Style the Button Groups The display suggests how to control the layout of an element. In this case, the inline-block of the display property displays ... Read More
To create a design like notes, we need to style it according with CSS on a web page. Consider the sticky notes provided by Google Keep. It provided different color label options. Let us see how to create some notes. Set Different Divs for Notes Here, we are creating three notes, representing danger success and information. We have set different divs − Danger!Operation may damage your computer Success!Operation has been performed successfully Info!Need more resources to perform this operation Danger Note For our ... Read More
To copy text to the clipboard, we will use the HTMLInputElement methods, select() and setSelectionRange(). With that, we have also used the document execCommand() method to copy. Create an Input Text We will create an input text. This will the text that we will copy to the clipboard Set a Button We will click this button to copy the clipboard text − Copy text You can also style the button accordingly − button { border: none; outline: none; background-color: rgb(191, 187, 255); ... Read More
The floats in CSS defines how an element should float. Let’s say, an element is taller than the element containing it. If it is floated, it will overflow outside of its container. Therefore, it’s hack is to use the overflow property and set the value auto. Without Clearfix Let us understand the issue by running the following program. Clearly, overflow occurs and the image moves outside − Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } ... Read More
To clear an input field, first create an input filed. To clear, use the onfocus attribute. Let us see with two examples. Create an Input Field First, use the input type to create an input field in a form on a web page − Clear the Input Field on Focus To clear the input field, use the onfocus attribute. Clear an Input Field on Focus The following is the code to clear an input field on focus − Clearing an input field on focus example Click on the above field to clear its value Clear Input Fields Let us see an ... Read More