Designing a website similar to sevenly.org using jquery: A step-by-step guide

My understanding of javascript and jquery is at a beginner level. I am interested in creating a design similar to Sevenly, where one page/div moves over another. I'm not sure where to begin with this. Any advice or ideas on how to implement this effect would be greatly appreciated.

Answer №1

If the first container has a defined height, one simple solution would be to make the first container fixed using position: fixed. You can then adjust the margin-top of the other containers to ensure they start just below the first container:

HTML:

<div id="header">Header</div>
<div id="rest">
    <div>Other 1</div>
    <div>Other 2</div>
    <div>Other 3</div>
</div>

CSS:

div#header{ 
    position: fixed;
    width: 100%;
    height: 150px;
    border: 2px dashed yellow; 
    background-color: lightyellow; 
}
div#rest{
    margin-top: 150px;
    position: relative;
}  
div#rest div{    
    height: 300px;
    border: 2px dashed green;
    background-color: lightgreen;
} 

The position: absolute; is used for browsers that do not support fixed positioning. Making it absolute will make it behave like fixed, but it will scroll along with the rest of the page. The position: relative; on the rest is necessary for z-stacking. Fixing the header container positions it on top of everything else; setting the rest to relative places it on top of the header again.

View the jsfiddle demo here.

If the header does not have a specific height, you may need to consider using javascript.

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

Issue with Vue directive bind not functioning after element refresh

My approach involves utilizing vue.js to create forms, where all fields are structured within a JavaScript objects array. Here is an example of the structure I use: { type: "input", mask: "date", default: "2018/04/14" }, { type: "input", ...

Tips for positioning an image next to a list in HTML:

Having recently entered the world of HTML coding, I am struggling to find a clear and precise solution to my issue. I am aiming to create a webpage that consists of a list of HTML elements. https://i.sstatic.net/jQ1o0.jpg Below is the HTML code I have w ...

Retrieve file using Ajax (kind of)

I have implemented an AJAX call in my GSP: $.ajax({ url: '${request.contextPath + '/Ticket/passAll'}', type: 'POST', data: data, success: function() { alert("Success"); } }); Below is a code snipp ...

Searching for different forms of multiple words using regular expressions

I have a value saved in a variable: var myvalue = "hello bye"; var myText = "hellobye is here and hello-bye here and hello.bye" Is there a way to check if different versions of myvalue are present in the text? I am currently using this pattern: hello ...

Creating PDF files from elements using Puppeteer JS

In my quest to master the usage of Puppeteer within a Vue.js application, I am facing a challenge. I am able to create a PDF based on the entire page successfully, but I am struggling to generate a PDF for a specific element on the page. Is there a method ...

Only displaying sub items upon clicking the parent item in VueJS

I'm in the process of designing a navigation sidebar with main items and corresponding sub-items. I want the sub-item to be visible only when its parent item is clicked, and when a sub-item is clicked, I aim for it to stand out with a different color. ...

What could be the reason for my button not updating its text using a method?

I attempted to change the inner text of the Edit button to Save after it's clicked using a method, but it doesn't seem to be working. I could really use some help with this. b-button.editbtn.d-flex.flex-row.mb-3(@click="editBlood") ...

Remove the background color from a semi-transparent circular CSS div when it is being dragged

My circular div is being dragged for a drag and drop operation, but there's always a translucent square around it. How can I remove this unwanted effect? body{ background : #BBD1DF; } .dragdemo { width: 170px; height: 170px; line-hei ...

What is the best way to cycle through the data within the Django template system?

On my blog page, I'm attempting to implement a feature where clicking on the blog title or read more link will redirect and display the detailed contents of the blogs. Model class Blog(models.Model): title = models.CharField(max_length=200) c ...

Struggling with handling numbers and special symbols in the Letter Changes problem on Coderbyte

Hello I have been struggling to find a solution for my current issue. The problem lies within an exercise that requires changing only alphabetical characters, but test cases also include numbers and special characters which are being altered unintentionall ...

Step-by-step guide on inserting a div element or hotspot within a 360 panorama image using three.js

As I work on creating a virtual tour using 360 images, I am looking to include hotspots or div elements within the image that can be clicked. How can I store data in my database from the event values such as angle value, event.clientX, and event.clientY wh ...

The height and rows of a textarea element do not adjust properly to the content in FireFox

Looking for a way to create a textarea with dynamic height that adjusts as the user adds new content? The resize property is set to none and overflow is hidden. It seems to be working correctly in Chrome, but Firefox is presenting some mysterious issues wi ...

What causes the content of a sticky navbar to overflow?

I have a situation where my navbar has two styles (.navbar and .navbar_fixed), but the links in the navbar are not fitting properly. I attempted to remove padding and add left: 0;, however, these adjustments did not work as expected. Any suggestions on how ...

Unveil as you scroll - ScrollMagic

I am working on a skill chart that dynamically fills when the document loads. I am exploring the possibility of using ScrollMagic to animate the chart filling as the user scrolls down. After trying various combinations of classes and pseudo-classes in the ...

leveraging parcel for importing typescript dependencies

I am currently using parcel to process typescript for a web extension. I have installed JQuery and its type definitions via npm. In my typescript file, I have the following at the top: import $ from "jquery"; import "bootstrap"; However, when running run ...

Troubleshooting $digest problems with AngularJS and the selectize directive

I am encountering difficulties when utilizing the watch function within a directive in conjunction with a third-party plugin named selectize. Despite researching extensively about $digest and $watch, I am still facing issues. Although my example below is ...

Issue with jQuery fadeIn() and fadeOut() functions on IE versions 7 and 8

I have a project in Ruby on Rails that showcases illustrations. The top of the page features category links that fade out the current illustrations, replace them with new content, and then fade back in. Currently, I am utilizing jQuery version 1.6.2 for t ...

Request the generic password prior to revealing the concealed div

I want to implement a feature where a hidden div is shown once a user enters a password. The password doesn't need to be stored in a database, it can be something simple like 'testpass' for now. Currently, I have written some code using Java ...

Transform a React component from a regular function to an ES6 class

Recently delving into ES6 and React, I found myself navigating through various ways to write a React component. My journey began with "React.createClass," then transitioned to utilizing "extends React.Component" with ES6 classes syntax. While following a ...

Changing images in vuejs

I am seeking to achieve a seamless transition between two images along with a corresponding legend. These images are sourced from an object-array collection. Since transitions operate only on single tags and components, I have devised a component to encap ...