小编Emm*_*t P的帖子

CSS Div 位置仅相对于视口顶部固定

有没有办法使用 CSS 使 div 的位置属性仅相对于视口的顶部固定?我想做的是制作一个随网页上下滚动的导航栏。

position: fixed 
Run Code Online (Sandbox Code Playgroud)

对此工作正常,除了当页面尺寸较小时会产生问题,因为用户无法水平滚动以访问屏幕外的导航栏选项。

也对其他非 CSS 解决方案开放,但如果有一些简单的东西我可以在 CSS 中实现,那将是更可取的。谢谢!

html css fixed css-position

3
推荐指数
1
解决办法
8296
查看次数

Python:为什么不是if(a == 0):a = 1 if(a == 1):a = 0用于进行切换

我正在研究一个使用python读取树莓派数字输入的项目.我想将其中一个按钮变成一个切换按钮,因为只要按下它就会在1和0之间切换一个值.一切都工作正常,除了部分:

if(a == 0.0):
    a = 1.0
if(a == 1.0):
    a = 0.0
Run Code Online (Sandbox Code Playgroud)

似乎这应该与其余的代码一起使用,只要按下按钮,值就会在1和0之间切换,但每次都打印为0.0,是否有人知道这是为什么?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
a = 0.0
b = 0.0
c = 0

while True:
    if(GPIO.input(4) ==1 and c ==0):
        print 'Button 1 Pressed'
        if(a == 0.0):
            a = 1.0
        if(a == 1.0):
            a = 0.0
        c = 1
        print a
    if(GPIO.input(4) !=1):
        c = 0
    if(GPIO.input(24) ==0):
        print 'Button 2 Pressed'
Run Code Online (Sandbox Code Playgroud)

python logic if-statement nested raspberry-pi

0
推荐指数
1
解决办法
136
查看次数

标签 统计

css ×1

css-position ×1

fixed ×1

html ×1

if-statement ×1

logic ×1

nested ×1

python ×1

raspberry-pi ×1