"Looking for a solution to create a fixed header alongside scrolling content? Plus, need

Is there a way to fix the header in place while allowing the content to scroll underneath it? Also, how can I position the CSS Play button above the line and make it visually appealing?

index.html:

<!DOCTYPE html>
<html>
<head>
    <title>lingo records</title>

    <meta charset="utf-8">
    <link rel="icon" href="/favicon.png">
    <link rel="author" href="http://forksforoatmeal.com">
    <link rel="stylesheet" href="/assets/css/lingo.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script src="/assets/js/jquery.jplayer.min.js"></script>
    <script src="/assets/js/lingo.js"></script>
</head>
<body>
    <div id="header">
        <h1 class="header">lingo records</h1>
        <ul id="navigation">
            <li><a href="#home">home</a></li>
            <li><a href="#about">about</a></li>
            <li><a href="#samples">samples</a></li>
            <li><a href="#contact">contact</a></li>
        </ul>
        <div id="music_player">
            <span id="pp"></span>
            <span id="song"></span>
        </div>
    </div>
    <div id="content">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
    <div class="clear">&nbsp;</div>
    <div id="footer">
        &copy; 2010 lingo records. <a href="http://forksforoatmeal.com">Josh Brown</a>
    </div>
    </body> 
    </html>

lingo.css:

/* Yahoo Style Reset Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html version: 2.8.1 */
html{color:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var,optgroup{font-style:inherit;font-weight:inherit;}del,ins{text-decoration:none;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:baseline;}sub{vertical-align:baseline;}legend{color:#000;}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;}input,button,textarea,select{*font-size:100%;}


body {
/*  background-color: #63B7D4;*/
    background-color: #fff;
    margin: 30px;
    font-family: 'Philosopher', sans-serif;
    font-size: 14px;
    color: #4F5155;
}

a {
    color: #475152;
    background-color: transparent;
    font-weight: normal;
}


h1.header {
    font-family: 'Philosopher', sans-serif;
    font-size: 70px;
    letter-spacing: -4px;
}

#header {
    position: static;
    border-bottom: 1px solid #D0D0D0;
}

#header #navigation a {
    font-family: 'Philosopher', sans-serif;
    font-size: 22px;
    text-decoration: none;
}
ul#navigation > li {
    display: inline;
    list-style-type: none;
    margin-right: 15px;
}

#header #navigation a:hover {
    text-decoration: underline;
}

#header #navigation a:last-child {
    margin-right: 0px;
}

#content {
    margin-top: 60px;
    font-size: 20px;
}


#footer {
    position: fixed;
    bottom: 0;
    right: 0;
    margin-bottom: 20px;
    margin-right: 20px;
    font-size: 12px;
}


/* Music Player */
#music_player {
    float:right;
    margin-right: 30px;
    margin-bottom: 5px;
    width: 250px;
}

.play {
    display:block;
    width:0;
    height:0;
    border-style:solid;
    border-width: 8px 0px 8px 16px;
    border-color:transparent transparent transparent #4F5155;

}
.pause{
    display:block;
    width:16px;
    height:16px;
    border-left:32px double #4F5155;
}

@font-face {
    font-family: Philosopher;
    src: url(/assets/fonts/Philosopher.otf);
    font-weight:400;
}

We appreciate your assistance! -Josh

Answer №1

To keep an element in place as the user scrolls, you can utilize the CSS property position: fixed. In order for the header contents to remain visible while scrolling, consider adding a semi-transparent background. Here is the necessary styling:

#header {
  position: fixed;
  width: 100%; /* Adjust width accordingly */
  background-color: rgba(255, 255, 255, 0.7); /* Consider using a semi-transparent png for IE compatibility */
  top: 10px;
}

#content {
  margin-top: 160px; /* Adjust top margin of content */
}

With regards to the music player, providing a link or sample would be beneficial for understanding the generated markup and required styles for optimal appearance.

Edit: Regarding the design of the music player button, utilizing background-image may provide a cleaner solution compared to using border to create shapes. Consider implementing something similar to:

#pp {
  background: url('path/to/image.png') no-repeat scroll left top;
  padding-left: 10px;
}

for the play button design.

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

Conceal Tooltips with Materialize CSS

I'm trying to figure out how to hide the tooltip that appears when hovering over this element using Materialize CSS. <li><a class="btn-floating green" onclick="window.print();return false;"><i class="material-icons tooltipped" data-pos ...

What is the method for calculating the difference in days between two Jalali dates when selecting the second date picker input?

I have integrated the Persian Datepicker script from GitHub to display jalali dates on my webpage. Users can select date1 and date2 from the datepicker to input their desired dates. Below is the code snippet: $(document).ready(function() { $('. ...

I've created a logo, but why are there two logos on my website?

There seems to be an issue with two divs stacking on top of each other, which is not the desired layout. This problem occurs when five div boxes are added. The goal is to have all divs in a single row, but it's unclear why this layout is not working ...

The email validation function is not functioning correctly when used in conjunction with the form submission

I'm currently working on my final project for my JavaScript class. I've run into a bit of a roadblock and could use some guidance. I am trying to capture input (all code must be done in JS) for an email address and validate it. If the email is va ...

Determine the total row count retrieved from a HTML table using Javascript

Currently, I have an HTML table that is being searched using JavaScript. I am looking to determine the number of rows that are remaining after the search and then display that information to the user. As a beginner, I would like some guidance on how to m ...

Can the individual headers of an ag-grid column be accessed in order to apply an on-mouseover event with a specific method?

In my current project, I am utilizing ag-grid to create a dynamic web-application that combines tools from various Excel files into one cohesive platform. One of the Excel features I am currently working on involves displaying a description when hovering ...

Avoid having the content below become pushed down by a collapsed navbar

I am utilizing Bootstrap 4.1 My current structure is as follows: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhkt ...

Is there a way to customize the look of the time selected in the <input matInput type="time" step="1" /> time picker?

Currently, I am utilizing the following code as a time picker in my Angular 9 application. My goal is to modify the selected time's color to a bright blue shade. How can I accomplish this task? <input matInput type="time" step="1&quo ...

Grab onto a nested section

What is the solution for targeting the h2 span element? div#content div.view-content div.view-row-item h2 span { ... doesn't seem to be doing the trick... ...

Responsive Design and the Importance of Setting Min-Width in Bootstrap 3

After doing some research on Stack Overflow about defining a minimum width for a responsive layout in Bootstrap3, I encountered conflicting answers related to "media queries." My goal is to make my layout responsive up to a certain point. Once it reaches, ...

I am experiencing an issue where the CSS code is not appearing in the Chrome Debugger when I inspect an element

I recently wrote some CSS code to remove default browser styles: /* Box sizing rules */ *, *::before, *::after { box-sizing: border-box; } ​ /* Remove default padding */ ul[class], ol[class] { padding: 0; } ​ /* Remove default margin */ body, h ...

Ways to stop VoiceOver from selecting the background content when a modal is open

Is there a way to prevent VoiceOver from reading the content behind a modal? I tried using aria-modal=true, but it seems VoiceOver does not support this feature by default like NVDA and JAWS do. I found more information about this on . According to the in ...

Having trouble with your GitHub Pages site displaying properly on desktop but working fine on mobile?

I am facing an issue with my GitHub pages site on a custom domain. It works perfectly fine on mobile, but when I try to access the same URL from desktop, I encounter a DNS_PROBE_FINISHED_NXDOMAIN error. Any suggestions on why this might be happening? You c ...

Applying custom CSS to individual divs based on their text height using jQuery

I have a grid consisting of multiple boxes each sized at 280px by 280px, and I am seeking a way to vertically align text within hover overlays on each box. While my current code successfully aligns the text for the first box, I am encountering issues due ...

Automatically resize ui-select dropdown box to the left side

I've been tasked with incorporating AngularJS ui-select into my project, specifically creating a multiselect dropdown. Currently, the dropdown box automatically adjusts its width based on the length of the longest selectable text, causing it to extend ...

Include the www when entering the URL to view the Wix.com page

My site is hosted by GoDaddy on projectprayerwindow.com. Everything runs smoothly, but when I enter www.projectprayerwindow.com instead, the expected results do not show up. Can someone offer assistance with this issue? ...

Ensure that each of the two divs maintains a 16:9 aspect ratio, and utilize one div to fill any remaining empty space through the

This layout is what I am aiming for: https://i.sstatic.net/uZdty.png While I can achieve a fixed aspect ratio with a 16:9 image by setting the img width to 100%, I run into an issue where the height scaling of flexbox becomes non-responsive. The height re ...

How to conceal 'subnavigation' elements within Buddypress

Hey everyone, I've been looking into how to hide subnav items in a drop-down list. Can this be achieved using just CSS or will I need to write some code for it to work properly? My main goal is to have the sub nav items appear when the user hovers ove ...

Use jQuery to place tags around the content of existing <li> elements

Using jquery, I have been able to successfully create a list by using the following code: $(list).append(item); (where list is the list reference and item consists of the $('<li>') elements being added). var item = $('<li>' ...

Elements displaying outside of block 'a' tag

I have a set of <a> elements that are styled with display:block. These contain various nested <divs>, for example: <a href="#" class="sliderframe"> <div class="container-caption"> <div class="slider ...