小编S. *_*ler的帖子

移动菜单打开时,身体的滚动锁定无效

我找到了几个其他解决方案,演示了如何使用CSS overflow属性锁定网站的滚动行为.因此,我已经实现了这个解决方案,并overflow: hidden;在菜单打开时添加到body标签.但是,当使用iOS Safari或Chrome时,正文仍然可滚动.

CSS:

    body.opened-drawer {
      overflow: hidden !important;
      height: 100% !important;
      width: 100% !important;
      position: fixed !important;
      z-index: 0 !important;
    }
Run Code Online (Sandbox Code Playgroud)

JS:

timber.openDrawerMenu = function () {
  var $mobileMenu = $('.nav-bar'),
      $mobileMenuButton = $('#menu-opener'),
      $body = $('body');
      $mobileMenuButton.addClass('opened');
      $mobileMenu.addClass('opened');
      $body.addClass('opened-drawer');

  // Make drawer a11y accessible
  timber.cache.$navBar.attr('aria-hidden', 'false');

  // Set focus on drawer
  timber.trapFocus({
     $container: timber.cache.$navBar,
     namespace: 'drawer_focus'
  });

  // Escape key closes menu
  timber.cache.$html.on('keyup.drawerMenu', function(evt) {
    if (evt.keyCode == 27) {
      timber.closeDrawerMenu();
    }
  });
}

timber.closeDrawerMenu …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

6
推荐指数
1
解决办法
2086
查看次数

Dotenv无法覆盖键值对

我正在尝试在节点服务器上使用 dotenv 实现环境变量,但是我无法从位于根目录中的 .env 文件加载它们。当我运行时const dotenv = require("dotenv").config({debug: true});,我遇到以下消息:"USER" is already defined in process.env and will not be overwritten

此外,当我尝试加载页面时,它遇到以下错误:ER_DBACCESS_DENIED_ERROR: Access denied for user ''@'localhost' to database '_api'

.env:

USER=root
PASS=
Run Code Online (Sandbox Code Playgroud)

javascript node.js dotenv

4
推荐指数
1
解决办法
8805
查看次数

flex-direction 在嵌套 Flexbox 网格中不起作用

我想使用 Flexbox 创建一个响应各种屏幕尺寸的网格。在纵向移动设备上,我希望网格仅为一列。至于横向移动,我希望网格变成两列,并让网格保持与一列中相同的顺序。对于桌面,网格应为三行,每行三列。

到目前为止,在两列布局中,每组三个弹性框后面都会创建一个空白空间。我希望下一个 Flexbox 能够填补这个空间,并希望有人能帮助我实现这一目标。

这是我正在复制的屏幕截图(桌面):

代码

    /* CSS Styles for the revised "Our */

/* Extra small devices (phones, less than 768px) */

.work__container {
   height: auto;
   display: flex;
   flex-direction: column;
}

.work__flex {
   width: 100vw;
   height: auto;
   display: flex;
   flex-direction: column;
}

.work__flex--item {
   width: 100vw;
   height: 100vw;
}

/* Mobile in landscape orientation */
@media (max-width: 767px) and (orientation: landscape) {
   
.work__flex {
   flex-direction: row;
   flex-wrap: wrap;
}
   
.work__flex--item {
   width: 50vw;
   height: 50vw;
}
  
    
} …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

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

AttributeError:“NoneType”对象没有属性“_instantiate_plugins”

我正在尝试开始使用 Flask 和 PostgreSQL 创建一个简单的项目。为了完整起见,我将在我的代码中包含所有终端命令。在我的 SQL_Example 文件夹和带有表“flights”的本地 PostgreSQL 数据库“lecture3”中工作:

$ python3 -m venv venv
$ . venv/bin/activate
$ pip install Flask
Run Code Online (Sandbox Code Playgroud)

现在我继续使用以下代码:

import os

from flask import Flask, render_template, request
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

app = Flask(__name__)

engine = create_engine(os.getenv("DATABASE_URL"))
db = scoped_session(sessionmaker(bind=engine))

@app.route("/")
def index():
    flights = db.execute("SELECT * FROM flights").fetchall()
    return render_template("index.html", flights=flights)

@app.route("/book", methods=["POST"])
def book():
    name = request.form.get("name")
    try:
        flight_id = int(request.form.get("flight_id"))
    except ValueError:
        return render_template("error.html", message="Invalid flight number.")

    if db.execute("SELECT …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy flask

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

Tailwindcss 框阴影未显示

我正在尝试在 React 项目中使用 Tailwindcss,在其中复制星球大战网站移动菜单。但是,当导航抽屉打开时,我添加到汉堡包图标段的框阴影不会显示。

沙箱链接:https://play.tai​​lwindcss.com/upmiAWTcso

索引.js

const toggleDrawer = (event) => {
  document.querySelector("#drawer").classList.toggle("left-[-100%]");
  document.querySelector("#drawer").classList.toggle("left-0");
  document.querySelector("#bar-1").classList.toggle("hidden");
  document.querySelector("#bar-2").classList.toggle("active-2");
  document.querySelector("#bar-3").classList.toggle("active-3");
};

<div
  onClick={toggleDrawer}
  className="h-full flex flex-col justify-center items-center space-y-[8px]"
>
  <span
    id="bar-1"
    className="block h-[2px] w-[30px] border-zinc-500 border-l-[4px] border-r-[20px] rounded-full transition-all duration-300"
  ></span>
  <span
    id="bar-2"
    className="block h-[2px] w-[30px] border-zinc-500 shadow-md border-l-[20px] border-r-[4px] rounded-full origin-bottom-right transition-all duration-300"
  ></span>
  <span
    id="bar-3"
    className="block h-[2px] w-[30px] border-zinc-500 shadow-md border-l-[4px] border-r-[20px] rounded-full origin-bottom-left transition-all duration-300"
  ></span>
</div>;
Run Code Online (Sandbox Code Playgroud)

全局.css

@layer components {
  .active-2 {
    @apply …
Run Code Online (Sandbox Code Playgroud)

css jsx reactjs tailwind-css

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

如何使用react-native解决“无法解析模块...”错误?

我正在尝试学习使用本机响应,并且正在关注此YouTube教程。我遇到了一个错误,指出以下内容:“无法从...解析模块...:无法将...解析为文件或文件夹。” 我可以肯定使用的文件路径是正确的,并且我已经非常仔细地跟踪了该视频,并且该视频似乎可以正常工作。对此的任何帮助将不胜感激,因为我不熟悉在React中使用组件。

index.js

import React, {Component} from 'react';
import { AppRegistry, Text, View } from 'react-native';
import App from './App';

import Component1 from './app/components/Component1/Component1';

export default class myapp extends Component {
  render() {
    return(

      <View>
        <Component1 />
      </View>

    );
  }
  constructor() {
    super();
  }
}

AppRegistry.registerComponent('myapp', () => myapp);
Run Code Online (Sandbox Code Playgroud)

component1.js

import React, {Component} from 'react';
import { AppRegistry, Text, View } from 'react-native';
import App from './App';

export default class Component1 extends Component {
  render() {
    return(

      <View> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native

2
推荐指数
1
解决办法
5452
查看次数

如何使用css flexbox创建水平滚动?

我想创建一个网页,其中有一个部分可以使用 Flexbox 水平滚动。但是,代码会导致每个框的尺寸减小以适合屏幕,而不是溢出并启用水平滚动。

代码:

.main {
  flex-direction: row;
  -webkit-flex-direction: row;
  overflow: scroll;
  width: 100%;
  height: 100vh;
}

.portfolio_item {
  width: 50%;
}

.flex {
  display: flex !important;
  display: -webkit-flex !important;
}
Run Code Online (Sandbox Code Playgroud)
<div class="main flex">
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

2
推荐指数
1
解决办法
1万
查看次数

意外的KeyError:在Python 2.7.10中

我是Python新编码的新手,我的代码遇到了意外错误.任何有关这方面的帮助将非常感激

import json
from urllib2 import urlopen

response = urlopen("https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json")
source = response.read()

# print(source)

data = json.loads(source)

# print(json.dumps(data, indent=2))

usd_rates = dict()

for item in data['list']['resources']:
    name = item['resource']['fields']['name']
    price = item['resource']['fields']['price']
    usd_rates[name] = price
    print name, price
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python python-2.7

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