css-position

CSS position:fixed without top gives unexpected layout?

邮差的信 提交于 2021-02-05 04:51:37
问题 Given: <body> <div id="fixed"> Fixed div </div> <div id="nonfixed"> <p>Non-fixed div</p> <p>Non-fixed div</p> <p>Non-fixed div</p> </div> </body> And: * { box-sizing: border-box; } body { margin: 0; padding: 0; } #fixed { position: static; width: 100%; border: 3px solid #f00; } #nonfixed { margin-top: 50px; border: 3px solid #00f; } Note that position:static , this gives the expected result (fiddle): However, change position:static to fixed , and you get this (fiddle) Even though the #fixed

CSS position:fixed without top gives unexpected layout?

邮差的信 提交于 2021-02-05 04:50:21
问题 Given: <body> <div id="fixed"> Fixed div </div> <div id="nonfixed"> <p>Non-fixed div</p> <p>Non-fixed div</p> <p>Non-fixed div</p> </div> </body> And: * { box-sizing: border-box; } body { margin: 0; padding: 0; } #fixed { position: static; width: 100%; border: 3px solid #f00; } #nonfixed { margin-top: 50px; border: 3px solid #00f; } Note that position:static , this gives the expected result (fiddle): However, change position:static to fixed , and you get this (fiddle) Even though the #fixed

CSS Position - top 100% Is Not Equal To bottom 0

你。 提交于 2021-02-04 16:35:08
问题 I noticed this when I assign fixed position to an element for css3 animation, that top: 100% isn't gave the same effect as bottom: 0; . It's locate the element outside of document, while bottom:0; is still showing the whole of the element. JSFIDDLE DEMO Is there an opposite of css position top:0; that is automatically give the same effect as bottom:0; ? 回答1: That is because top value takes the top edge as a reference point, you need to use transform: translateY(-100%) to make the bottom edge

object-fit, object-positioning and absolute positioning

限于喜欢 提交于 2021-02-02 09:27:51
问题 Whilst trying to make an image fit into a rectangle, I came across a weird problem and wondered if anyone knew why these three ways of using object fit act differently: .container { width: 250px; padding-top: 20%; border: 1px solid red; position: relative; display:inline-block } .container>img { position: absolute; top: 0; left: 0; object-fit: contain; object-position: center center; } .image { width: 100%; height: 100%; } .image-1 { right: 0; bottom: 0; } .image-2 { right: 0; bottom: 0; max

Padding changes when the browser is zoomed in or out

痴心易碎 提交于 2021-01-29 11:29:25
问题 I have a thumbnail image and another smaller image which overlaps the thumbnail image. But the padding changes for the smaller overlapping image as I zoom in and out and the problem exist only with the CHROME browser. Its working fine with IE and firefox. I tried using percentage to set the padding values for the smaller image but the problem still exist. Here are the images. This is the HTML <div class="car-item"> <div class=" car-image"> <img src="/~/media/images/thumb.ashx" alt="Image 1" /

Fixed Header & Fixed Column Table

旧街凉风 提交于 2021-01-28 05:51:35
问题 I have a problem with my fixed header and fixed column table. The header is fixed but the column isn't. So how do I fix this problem? I have tried to give the first column position: fixed but it doesn't work right. If possible without Javascript. (I have tried to find solutions from earlier questions of the same topic but none of those helped me). Here is my Codepen. body { background-image: url(http://absfreepic.com/absolutely_free_photos/small_photos/green-grass-football-lawn-4020x2261

Why my sticky navigation only works when my header is set to be inline?

梦想的初衷 提交于 2021-01-28 03:36:42
问题 This is my HTML file: .jumbotron { font-size: 20px; padding: 60px; background-color: #00a8ec; text-align: center; color: white; } header { display: inline; } nav { background-color: #00b2a6; padding: 5px; position: sticky; top: 0; } footer { padding: 20px; color: white; background-color: #00b2a6; text-align: center; font-weight: bold; } <!DOCTYPE html> <html> <head> <title>TITLE</title> <link rel="stylesheet" href="tes.css"> </head> <body> <header> <div class="jumbotron"> <h1>TITLE</h1> <p

center one div above two other divs

↘锁芯ラ 提交于 2021-01-27 19:24:46
问题 I would like to achieve this situation: The page contains 4 divs in total. The main layer is divided in 3 divs. Above div1 and div2, another div(div4) must be floating above them in the middle of these 2 divs. current code: body { position:relative; } div1 { // nothing } div2 { // nothing } div3 { // nothing } div4 { z-index: 10; position: absolute; top: 550px; left: 0; margin-left: auto; margin-right: auto; width: 50%; padding: 50px; } I would appreciate it if anyone could give me a heads up

CSS outline width not working

早过忘川 提交于 2021-01-27 13:02:54
问题 I am trying to set outline width of the input element on focus. Outline width stays the same (like it is default setting which can not be changed), no matter of my setting. Here is example from code pen And here is part from css where I am trying to set outline-width on focus: input:focus { outline-width: 0.1px; outline-color: #725b44; } EDIT: I've just forgotten to include line style (solid, dotted...). Now it works. One thing is still strange to me. Why is outline inside element? Isnt' the

How to enable CSS position: sticky in mobile browsers?

坚强是说给别人听的谎言 提交于 2021-01-21 12:23:31
问题 Added some position: sticky property to my webpage. On Desktop browser work fine but sucks in mobiles. 回答1: sticky property for Chrome and Safari for iOS needs to be set with -webkit vendor first: .element { position: -webkit-sticky; position: sticky; } You can check about browser compatibility in canIUse 来源: https://stackoverflow.com/questions/45249771/how-to-enable-css-position-sticky-in-mobile-browsers