码迷,mamicode.com
首页 > Web开发 > 详细

[CSS3] Use Sticky Positioning for Section Headers

时间:2018-06-17 12:38:20      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:and   mil   rpo   stl   diff   ted   eve   for   use   

We can take advantage of sticky positioning to keep a section header at the top of the page while the user scrolls. This is useful for neat categorisation of sections on the page.

  <dl>
    <dt>Premier League</dt>
    <dd>Brighton & Hove Albion 2 - 2 AFC Bournemouth</dd>
    <dd>Burnley 1 - 2 Liverpool</dd>
    <dd>Leicester City 3 - 0 Huddersfield Town</dd>
    <dd>Stoke City 0 - 1 Newcastle United</dd>
    <dd>Everton 0 - 1 Manchester United</dd>

    <dt>Championship</dt>
    <dd>Bolton Wanderers 1 - 0 Hull City</dd>
    <dd>Derby County 1 - 1 Sheffield United</dd>
    <dd>Leeds United 0 - 0 Nottingham Forest</dd>
    <dd>Norwich City 2 - 1 Millwall</dd>
    <dd>Preston North End 2 - 3 Middlesbrough</dd>
    <dd>Queens Park Rangers 2 - 1 Cardiff City</dd>
    <dd>Sheffield Wednesday 0 - 3 Burton Albion</dd>
    <dd>Sunderland 0 - 1 Barnsley</dd>
    <dd>Aston Villa 3 - 0 Bristol City</dd>

    <dt>League 1</dt>
    <dd>AFC Wimbledon 2 - 0 Southend United</dd>
    <dd>Bristol Rovers 2 - 1 Portsmouth</dd>
    <dd>Charlton Athletic 1 - 2 Gillingham</dd>
    <dd>Fleetwood Town 1 - 2 Bradford City</dd>
    <dd>Northampton Town 0 - 1 Wigan Athletic</dd>
    <dd>Oxford United 3 - 1 Milton Keynes Dons</dd>
    <dd>Peterborough United 1 - 1 Doncaster Rovers</dd>
    <dd>Plymouth Argyle 1 - 0 Walsall</dd>
    <dd>Rochdale 1 - 2 Blackpool</dd>
    <dd>Rotherham United 1 - 1 Blackburn Rovers</dd>
    <dd>Scunthorpe United 1 - 0 Bury</dd>
    <dd>Shrewsbury Town 1 - 0 Oldham Athletic</dd>
  </dl>
dl {
  font-size: 30px;
}

dt {
  background-color: mediumseagreen;
  position: sticky;  /*sticky positioning*/
  position: -webkit-sticky;
  top: 0;
}

dd {
  padding: 20px 0;
}

 

 

[CSS3] Use Sticky Positioning for Section Headers

标签:and   mil   rpo   stl   diff   ted   eve   for   use   

原文地址:https://www.cnblogs.com/Answer1215/p/9192527.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!