logo
down
shadow

div image position fixed + scroll


div image position fixed + scroll

Content Index :

div image position fixed + scroll
Tag : html , By : user91848
Date : November 24 2020, 01:01 AM

Does that help It's about choosing the right approach. This type of scrolling can easily be done by a fixed menu (which you have at the top), a pushed-down div and a background image. I added a nice reusable cat image to show the effect.
You were almost there, just needed to give the nav a fixed position.
* {
  padding: 0;
  margin: 0;
}
body {
  background: url(https://c1.staticflickr.com/9/8226/8557105873_a82c51f03f_z.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
nav {
  background-color: #555555;
  text-align: center;
  height: 20px;
  position: fixed;
  top: 0px;
  width: 100%;
}
nav li {
  display: inline;
  list-style-type: none;
  padding-right: 20px;
}
nav li a {
  color: white;
  text-decoration: none;
}
.text {
  background-color: orange;
  margin-top: 500px;
  min-height: 1000px;
}
<html>

<body>
  <nav>
    <ul>
      <li><a href="#">Link 1</a>
      </li>
      <li><a href="#">Link 1</a>
      </li>
      <li><a href="#">Link 1</a>
      </li>
    </ul>
  </nav>

  <div class="text">
    text
  </div>

</body>

</html>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to make an element fake position:fixed so it acts fixed until a certain scroll height, then attaches?


Tag : javascript , By : Aki Björklund
Date : March 29 2020, 07:55 AM
wish helps you You can set position to absolute and attached scroll event to the page and in that event you change top css value based on position of scrollbar (in jQuery it's scrollTop in pure javascript it should be similar), and then you add condition that top is changed only if scrollTop is less then specific value like offset.top + height of the sidebar.

make image element fixed position and doesn't move on scroll


Tag : css , By : KS9
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Have you specified a DOCTYPE decalaration in your markup? This should work:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> 

div having fixed height and fixed position make inner content scroll


Tag : html , By : mtnmuncher
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Try overflow-y:scroll Fiddle.This has a container just to show that the position will be maintained
.fixed {
    height: 200px;
    position: fixed;
    top: 50px;
    
    overflow-y:scroll;
}
<div class="fixed">
    <div class="content">
        <h1>
            title1
        </h1>
        <h1>
            title2
        </h1>
        <h1>
            title3
        </h1>
        <h1>
            title4
        </h1>
        <h1>
            title5
        </h1>
        <h1>
            title6
        </h1>
        <h1>
            title7
        </h1>
    </div>
</div>        
        

css make background image position fixed and scroll content up


Tag : html , By : Manik
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , How can we do something similar as done in this example http://theme.nileforest.com/html/mazel-v1.1/home-text-rotator1.html
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
.block-parallax-1 {
    overflow: hidden;
    position: relative;
}
.block-parallax-1 .parallax-bg {
    background-attachment: fixed;
    background-image: url('http://bygaga.com.ua/uploads/posts/1354003535_podborka_krasivih_moto_759-58.jpg');
    background-position: 0px 0px;
    background-repeat: repeat;
    height: 100%;
    position: absolute;
    width: 100%;
    min-width: 1170px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    background-size: cover;
}
.block-parallax-1 .md-box {
    padding: 200px 0 200px;
    background: rgba(0, 0, 0, 0.75);
    position: relative;
    height: 100%;
    text-align: center;
}
.block-parallax-1 .md-box h1 {
    color: #fff;
}

.block-parallax-2 .parallax-bg { 	
	background-image: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ_z73DvFVC1ek9ZsGdCpvpDW_AwRqOWgG6IP2wOXrVibxz_EDV');
}



h2 {
    color: #555;
    text-align: center; 
    padding: 25px 0;
    margin: 0;
}
<section class="block-parallax-1">
    <div class="parallax-bg"></div>
    <div class="md-box">
         <h1>background-attachment:fixed</h1>
    </div>
</section>
    
    <section style="min-height:400px;">
        <h2>background</h2>
 <p></p>
    </section>

<section class="block-parallax-1  block-parallax-2">
    <div class="parallax-bg"></div>
    <div class="md-box">
         <h1>background-attachment:fixed</h1>
    </div>
</section>

Image resizes when position is changed to fixed on scroll


Tag : javascript , By : acolomba
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Position fixed means that an element will have relative sizes and positioning in relation to the viewport, not their parent elements.
Specifically what is happening here is that your div with ID article1Media is set to have a width of 48%. When it has the CSS property of position: relative then that resolves as 48% of the width of it's containing element (the div with id article1) however when it is position fixed that resolves as 48% of the width of the viewport. Since there is an implicit 8px margin on the element then these are different.
body{
    margin:0px;
}

.image{
    margin:8px;
}
.image{
    width:500px;
}

@media(min-width:800px){
    width:300px;
}
.media.image-fixed{
  position:fixed;
  width:calc(48% - 8px);
}
Related Posts Related QUESTIONS :
  • svg hexagon halftone pattern
  • How to edit a website's element's background colors using a chromium extention
  • What is the main tag in HTML5 ? How does it differ from body tag?
  • My image is flowing out from my div column. How I can fix it and made the image full-size into div
  • How to draw line in react
  • Why Transition css is not working in child selector css
  • How to modify materialize css select option?
  • How to center some text in a rectangle in CSS?
  • How do I equally space out css grid columns?
  • How to make sure all the parts of a macro are running correctly?
  • How to adjust the zoom of website at different browser at different screen size?
  • Can't set max height on child div properly
  • Why background color is not applying to DIV container?
  • Need to select the first-child
  • No space between attributes in buttons
  • How can I block google from crawling my page, but still let Baidu do it?
  • Rendering html content in matToolTip (Angular)
  • Embedding an iframe when iframe height is variable
  • How to use 'word-break: break-word' with link inside of text?
  • How I can animate circular progress bar from left to right?
  • Angular 6 - How can I hide a div onclick of outside of that div
  • How to fill an inline-block div with a solid color?
  • Form file doesn't align with rest of form
  • How to trim off left and right sides of image evenly as I reduce my screen size? (@media query)
  • How can I password protect a section of a static website?
  • Move a div up when I hover over it
  • Why is "align" not a valid attribute of div but still works?
  • Behavior with height/minHeight and display:flex
  • How can i change my h2 title to <p> text while keeping size and alignment?
  • Hover on the text to change size using CSS
  • How to keep a grid of cols without breaking on a new row?
  • Why is bottom: 0 not enough to move ::after content directly below main content?
  • Why does a React build need to be served? Why can't I just open it in the browser?
  • What is the proper way to target the tab key 'highlight' events on an html element?
  • How to Implement dot and line below the text in CSS?
  • DIVs not properly aligned
  • HTML 'for' tag not working for <p> but works on <label>
  • <p> element does not appear to be within parent <footer> element
  • Why flex container is smaller than its content
  • Center an image and a text in a div
  • .class with display: none -> .class:focus with display: block; causes links to not work
  • Best way to use a right pointing arrow in CSS animation
  • Angular 7 : Select tag doesn't display options
  • Orientation: Landscape showing true for desktop
  • How to adjust text in a table
  • React Button Click Event Not Firing - One Button Works, One Button Doesnt
  • Angular Material: using mat-sidenav, cannot read property 'toggle' of undefined
  • Share image whatsapp not visible
  • Why does ImageResizer increase the loading time?
  • Can someone help figure out whats wrong with my answer on testdome?
  • Safari Viewport Bug, Issues with Fixed Position and Bottom or Top
  • Why does SVG produce blurry image in Firefox for large ViewBox dimensions
  • Do `overflow-wrap: break-word` and `word-break: break-word` ever behave differently?
  • Visual Studio Code: How to remove html tags and write to multiple lines at the same time?
  • How to make a row of images a vertically and horizontally centered div?
  • How to use specificity with css?
  • can't assign two style in different tag
  • How to add custom-logo/image in toolbar using vuetify
  • How can I get a space to take up space?
  • Setting the flex values to make the label appear correctly when container width is small?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com