小编And*_*man的帖子

将内联块DIV与容器元素顶部对齐

当两者inline-block div的高度不同时,为什么两者中的较短者不对齐容器的顶部?(演示):

.container { 
    border: 1px black solid;
    width: 320px;
    height: 120px;    
}

.small {
    display: inline-block;
    width: 40%;
    height: 30%;
    border: 1px black solid;
    background: aliceblue;    
}

.big {
    display: inline-block;
    border: 1px black solid;
    width: 40%;
    height: 50%;
    background: beige;    
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
    <div class="small"></div>
    <div class="big"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

如何对齐div容器顶部的小?

css

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

如何在没有页面重新加载的情况下在ajax中成功更改URL

这是ajax

$(".urut").change(function() {
  $.ajax({
    url: "<?php echo base_url(); ?>categories/brand/<?= $link_brand; ?>?l=<?= $l; ?>&h=<?= $h; ?>&city=<?= $city; ?>&city_name=<?= $city_name; ?>&ket=view",
    type: "POST",
    data: "urut=" + $(".urut").val(),
    success: function(data) {
      $("#result").html(data);
    }
  })
})
Run Code Online (Sandbox Code Playgroud)

这是有效的,但我想要更改网址,因为我有很多参数,当然还有data: "urut="+$(".urut").val(),参数.

javascript php ajax jquery

20
推荐指数
3
解决办法
4万
查看次数

如何将附加参数传递给 useSelector

useSelector从一个组件成功调用,该组件从 id 派生产品名称。

const productId = 25; // whatever

const productName = useSelector(
  (state) =>
    state.dashboard.dashboards.filter(
      ({ Id }) => Id === productId
    )[0].Name
);
Run Code Online (Sandbox Code Playgroud)

但是,我的选择器依赖于productId,我将其存储在同一文件的变量中。我想将此useSelector调用存储在外部文件中,以便共享。我尝试以下,但idundefined

选择器.js

const productId = 25; // whatever

const productName = useSelector(
  (state) =>
    state.dashboard.dashboards.filter(
      ({ Id }) => Id === productId
    )[0].Name
);
Run Code Online (Sandbox Code Playgroud)

some_file.js

import { useSelector } from "react-redux";
import { getProductNameById } from "./selectors";

const productId = 25;
const productName = useSelector(getProductNameById, …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux

14
推荐指数
2
解决办法
6313
查看次数

启动我的项目时出错(运行ng serve之后)

我从正在学习的在线MOOC中下载了该项目的zip文件。到现在为止一切正常,但是现在我遇到了如下所述的错误:

我尝试ng serve再次运行,并且也npm install再次运行,但是每次遇到以下错误时:

node_modules / rxjs-compat / operator / shareReplay.d.ts(2,10)中的错误:错误TS2305:模块'“ / Users / ratnabhkumarrai / Downloads / prj-http-final 3 / node_modules / rxjs / internal-compatibility / index “”没有导出的成员'ShareReplayConfig'。

import { Observable, SchedulerLike } from 'rxjs';
import { ShareReplayConfig } from 'rxjs/internal-compatibility';
/**
* @method shareReplay
* @owner Observable
*/
export declare function shareReplay<T>(this: Observable<T>, config: 
ShareReplayConfig): Observable<T>;
export declare function shareReplay<T>(this: Observable<T>, 
bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike): 
Observable<T>;
Run Code Online (Sandbox Code Playgroud)

node-modules angular

10
推荐指数
2
解决办法
9607
查看次数

JavaScript中的简单变异观察器示例不起作用

我尝试MutationObserver在我的网页中添加一个跟踪图像中的更改src,但这不起作用.

这是使用的代码:

setTimeout(function() {
  document.getElementById("img").src = "http://i.stack.imgur.com/aQsv7.jpg"
}, 2000);

var target = document.querySelector('#img');

var observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    console.log(mutation.type);
  });
});

var config = {
  attributes: true,
  childList: false,
  characterData: false
};

observer.observe(target, config);
observer.disconnect();
Run Code Online (Sandbox Code Playgroud)
<img src="http://i.stack.imgur.com/k7HT5.jpg" id="img" class="pic" height="100">
Run Code Online (Sandbox Code Playgroud)

javascript mutation-observers

9
推荐指数
1
解决办法
8903
查看次数

在contenteditable中限制粘贴(HTML/JS)

我想阻止用户在contenteditablediv中粘贴不允许的标记.

我想将粘贴限制为粗体,斜体,打击,下划线和链接.

什么是最好的方式(我正在使用jQuery)?

这不是JQuery Text Editor Paste Without Formatting的重复.我不想在没有格式化的情况下粘贴.我想选择/限制一些标记.

我已经阅读了以下问题,没有提供明确答案:

html javascript jquery contenteditable

7
推荐指数
1
解决办法
435
查看次数

网络推送通知未显示

我注册了一个服务人员,并尝试在浏览器中测试网络通知。Chrome(和 Firefox)声称 Service Worker 已成功注册。

在此输入图像描述

在加载 React 应用程序时,我已授予接收通知的权限。

在此输入图像描述

在我的 中sw.js,我正在侦听一个push事件,并尝试从 Chrome 应用程序选项卡发送示例推送消息,如上面的屏幕截图所示。

self.addEventListener("push", receivePushNotification);
Run Code Online (Sandbox Code Playgroud)

Push单击Chrome 应用程序选项卡时,push会触发该事件,并调用receivePushNotification. 但是,当我尝试在浏览器中显示通知时,没有任何反应,也没有报告错误。

function receivePushNotification(event) {
  // This prints "Test push message from DevTools."
  console.log("[Service Worker] Push Received.", event.data.text());

  var options = {
    body: "This notification was generated from a push!"
  };

/*****
  I would expect the following line to display a notification, since I've already 
  granted permission to allow for notifications. Yet, nothing happens and there …
Run Code Online (Sandbox Code Playgroud)

javascript push-notification web web-notifications service-worker

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

在Opera浏览器中找不到麦克风"允许"按钮

根据caniuse,Opera支持语音识别API.但是,在尝试查看简单示例时,我无法在单击麦克风图标时找到"允许"按钮.在Chrome中,首次点击麦克风图标时会立即弹出允许麦克风对话框.

我正在测试干净安装的Opera 39/Mac.

在此输入图像描述

javascript browser opera speech-recognition

5
推荐指数
1
解决办法
1626
查看次数

一个带有两个链接的fa图标

我做了一个看起来像这样的菜单: 在此输入图像描述,但我在最后一次行动中的麻烦 - 认证.这就是我得到的:在此输入图像描述.

编辑:第一张图片很宽,不适合Stack Overflow提供的空间.这是该图像的链接,显示了OP想要的样子.

我的代码:

.navbar-nav li a {
  display: inline-block;
  font-size: 18px;
  color: #d1d1d1;
  vertical-align: middle;
}

.navbar-nav li a:hover {
  color: #efa843;
}

.nav-item {
  margin-right: 32px;
}
Run Code Online (Sandbox Code Playgroud)
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="header">
  <div class="container">
    <nav class="navbar navbar-expand">
      <div class="collapse navbar-collapse" id="header_menu">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item">
            <a class="nav-link" href="#"><i class="fas fa-heart fa-2x" style="vertical-align: middle;"></i> ??? ???????</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#"><i …
Run Code Online (Sandbox Code Playgroud)

html css font-awesome bootstrap-4

5
推荐指数
1
解决办法
82
查看次数

在行之间更改CSS Grid垂直间隙

如何更改每个网格行之间的垂直间隙?

在此输入图像描述

我尝试过grid-gap,但这只会改变水平间隙 - 而不是垂直间隙.任何帮助,将不胜感激.

.wrapper {
  background-color: #1c1c1c;
  border: solid black 1px;
  margin-left: auto;
  margin-right: auto;
  width: 1000px;
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: 'header header header header header' 'menu content content content content' 'menu content content content content' 'footer footer footer footer footer';
}

.header {
  grid-area: header;
  border: solid white 1px;
  background-color: #3a3a3a;
  margin: 10px;
}

.menu {
  grid-area: menu;
  border: solid white 1px;
  background-color: #3a3a3a;
  margin: 10px;
} …
Run Code Online (Sandbox Code Playgroud)

html css css-grid

5
推荐指数
2
解决办法
172
查看次数