INFORMATION & CODE
Scrolling Cards Display
What the Code Does and How it Works
The code creates a horizontal scrolling card layout for displaying information about several people. Each card contains a circular photograph, a person’s name, a short biographical description, and a longer paragraph. The HTML provides the structure, while the CSS controls the appearance, spacing, colours, sizing, and scrolling behaviour. The JavaScript file is linked but currently contains no code, so it does not perform any additional actions.
The <main> element contains the overall .card-wrapper, which centres the card area and gives the page a light-blue background. Inside it, .card-container holds four individual .card elements. Each card follows the same structure: an image, an <h2> for the name, an <h3> for the biographical description, and a <p> for additional information. The image URLs can be replaced with your own image URLs, and the placeholder text can be replaced with the actual person's information.
The .card-container uses display: flex to place the cards horizontally. Its overflow-x: scroll property allows the user to move left and right through the cards when they do not all fit within the available width. The scroll-snap-type: x mandatory and scroll-snap-align: start properties make the scrolling snap neatly from one card to the next. The custom ::-webkit-scrollbar rules also change the appearance of the horizontal scrollbar.
The .card styles control the individual cards. They are given a white background, rounded corners, padding, and a shadow. The flex: 0 0 100% rule makes each card occupy the full available width of the scrolling container, creating a one-card-at-a-time carousel-style layout. The .image and .image img rules make each person's photograph circular, with a green outer border/background and a white border around the image.
How to Use the Code
To use the code, save the HTML as something such as index.html and the CSS as styles.css in the same folder. Replace the image URLs, names, descriptions, and paragraph text with your own content. You can add or remove .card sections as required. The scripts.js file is not currently needed because it contains no JavaScript, although it can be used later if you want to add features such as navigation buttons, automatic scrolling, or interactive effects.