RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

全部问题

Martin Hope
rikimaru2013
Asked: 2020-01-29 23:51:43 +0000 UTC

函数是函子吗

  • 9

函数是函子吗?

函数可以在STL算法中用作函子,但出于某种原因书籍固执地证明函数是函数,函子只是对象

c++
  • 3 个回答
  • 10 Views
Martin Hope
Vadim Prokopchuk
Asked: 2020-01-25 04:11:10 +0000 UTC

初始化 C# 结构

  • 9

为什么在有构造函数的情况下还要初始化C#值类型中的所有字段?

例如,下面的代码将不会编译

struct AAA
{
    public int A;
    public string C;

    public AAA(int a)
    {
        A = a;
    }
}

AAA.C 字段必须在控制返回到调用方法之前完全限定。

但是如果我们删除构造函数,那么一切都会编译

struct AAA
{
    public int A;
    public string C;
}
c#
  • 1 个回答
  • 10 Views
Martin Hope
Yuri
Asked: 2020-01-18 23:41:07 +0000 UTC

顶部菜单实现

  • 9

有一天,我在没有使用脚本的情况下绘制了顶级菜单的代码。一切顺利,但对吗?事实上,我用于造型input type="checkbox"等等pointer-events: none;。项目中有这样的实现吗,还是这种情况还是用JS比较好?

菜单代码:

body {
  font-family: Tahoma, Arial
}
.topbar {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background-color: white;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}
.topbar__button-open-leftmenu {
  display: block;
  width: 24px;
  height: 24px;
  padding: 8px;
  cursor: pointer;
}
.topbar__button-open-leftmenu:hover {
  border-bottom: 2px solid #1C90F3;
}
.topbar__button-open-leftmenu svg path {
  fill: #333;
}
.topbar__button-open-leftmenu:hover svg path {
  fill: #000;
}
.topbar__memu {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 auto 0 0;
  opacity: 1;
  transform: translateX(0);
  transition: all 0.4s ease;
  pointer-events: auto;
}
.topbar__memu li {
  transform: scale(1);
  transition: all 0.6s ease;
  opacity: 1;
}
.topbar__memu li:nth-child(1) {
  transition-delay: 0s;
}
.topbar__memu li:nth-child(2) {
  transition-delay: 0.1s;
}
.topbar__memu li:nth-child(3) {
  transition-delay: 0.2s;
}
#topbar__checked-search:checked ~ .topbar__memu li:nth-child(1) {
  transform: scale(0);
  transition-delay: 0.2s;
  opacity: 0;
  pointer-events: none;
}
#topbar__checked-search:checked ~ .topbar__memu li:nth-child(2) {
  transform: scale(0);
  transition-delay: 0.1s;
  opacity: 0;
  pointer-events: none;
}
#topbar__checked-search:checked ~ .topbar__memu li:nth-child(3) {
  transform: scale(0);
  transition-delay: 0s;
  opacity: 0;
  pointer-events: none;
}
.topbar__memu-item {
  display: block;
  height: 40px;
  padding: 0 10px;
  line-height: 40px;
  font-size: 0.8rem;
  color: #333;
  text-decoration: none;
}
.topbar__memu-item:hover {
  color: #000;
  border-bottom: 2px solid #1C90F3;
}
.topbar__button-open-search {
  display: block;
  position: relative;
  width: 40px;
  height: 40px;
}
.topbar__button-open-search:hover {
  background-color: #f5f5f5;
}
.topbar__button-open-search svg {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 20px;
  height: 20px;
}
.topbar__button-open-search svg path {
  fill: #333;
}
.topbar__button-open-search:hover svg path {
  fill: #000;
}
.topbar__button-open-search svg#icon-serach-close {
  opacity: 1;
  transition: all 0.4s ease;
}
.topbar__button-open-search svg#icon-serach-open {
  opacity: 0;
  transition: all 0.4s ease;
}
#topbar__checked-search:checked ~ .topbar__button-open-search svg#icon-serach-close {
  opacity: 0;
  transition: all 0.4s ease;
}
#topbar__checked-search:checked ~ .topbar__button-open-search svg#icon-serach-open {
  opacity: 1;
  transition: all 0.4s ease;
}
#topbar__checked-search {
  display: none;
}
.topbar__search {
  display: block;
  position: absolute;
  left: 50%;
  top: 0;
  width: 60%;
  height: 30px;
  padding: 5px;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.4s ease;
  pointer-events: none;
}
#topbar__checked-search:checked ~ .topbar__search {
  transition-delay: 0.6s;
  opacity: 1;
  pointer-events: auto;
}
.topbar__search-input {
  display: block;
  width: calc(100% - 40px);
  height: 30px;
  padding: 0 30px 0 10px;
  border: none;
  border-radius: 3px;
  background-color: #f4f4f4;
  font-family: inherit;
  outline: none;
  transition: background 0.2s ease;
}
.topbar__search-input:focus {
  background-color: #eeeeee;
}
.topbar__search-button {
  display: block;
  position: absolute;
  top: 11px;
  right: 12px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.topbar__search-button svg path {
  fill: #333;
}
.topbar__search-button:hover svg path {
  fill: #000;
}
.topbar__search-panel {
  display: block;
  position: fixed;
  top: 42px;
  left: 0px;
  width: 100%;
  height: calc(100vh - 42px);
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}
#topbar__checked-search:checked ~ .topbar__search-panel {
  opacity: 1;
  pointer-events: auto;
}
.topbar__search-panel-list {
  display: block;
  position: absolute;
  top: 10px;
  left: 50%;
  width: 60%;
  padding: 5px 0;
  border-radius: 2px;
  transform: translateX(-50%) translateY(-20%);
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.4s ease, opacity 0.4s ease;
  opacity: 0;
}
#topbar__checked-search:checked ~ .topbar__search-panel .topbar__search-panel-list {
  transition-delay: 0.6s;
  transform: translateX(-50%) translateY(0%);
  opacity: 1;
}
.topbar__search-panel-list:before {
  display: block;
  content: 'Результаты поиска:';
  font-size: 0.8rem;
  padding: 3px 10px;
  margin: 0 0 5px 0;
  color: #acacac;
  border-bottom: 1px solid #f2f2f2;
}
.topbar__search-panel-list-item {
  display: block;
  font-size: 0.8rem;
  padding: 3px 10px;
  color: #333;
  text-decoration: none;
}
.topbar__search-panel-list-item:hover {
  background-color: #f4f4f4;
}
/* Leftmenu */

.leftmenu {
  display: block;
  position: fixed;
  top: 42px;
  left: 0px;
  width: 100%;
  height: calc(100vh - 42px);
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
#topbar__checked-leftmenu:checked + .leftmenu {
  opacity: 1;
  pointer-events: auto;
}
.leftmenu__list {
  display: block;
  position: absolute;
  left: -200px;
  width: 200px;
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: white;
  transition: left 0.4s ease;
}
#topbar__checked-leftmenu:checked + .leftmenu .leftmenu__list {
  left: 0;
}
.leftmenu__list-item {
  display: block;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: #333;
  text-decoration: none;
}
.leftmenu__list-item:hover {
  background-color: #f4f4f4;
}
.leftmenu__hidemenu {
  display: block;
  position: absolute;
  left: 200px;
  top: 0;
  width: calc(100% - 200px);
  height: 100%;
}
<div class="topbar">
  <label for="topbar__checked-leftmenu" class="topbar__button-open-leftmenu">
    <svg viewBox="0 0 32 32">
      <path d="M 16 6 C 14.895431 6 14 6.8954305 14 8 C 14 9.1045695 14.895431 10 16 10 C 17.104569 10 18 9.1045695 18 8 C 18 6.8954305 17.104569 6 16 6 z M 16 14 C 14.895431 14 14 14.895431 14 16 C 14 17.104569 14.895431 18 16 18 C 17.104569 18 18 17.104569 18 16 C 18 14.895431 17.104569 14 16 14 z M 16 22 C 14.895431 22 14 22.895431 14 24 C 14 25.104569 14.895431 26 16 26 C 17.104569 26 18 25.104569 18 24 C 18 22.895431 17.104569 22 16 22 z"></path>
    </svg>
  </label>
  <input type="checkbox" id="topbar__checked-search">
  <ul class="topbar__memu">
    <li><a href="" class="topbar__memu-item">Пункт 1</a>
    </li>
    <li><a href="" class="topbar__memu-item">Пункт 2</a>
    </li>
    <li><a href="" class="topbar__memu-item">Пункт 3</a>
    </li>
  </ul>
  <div class="topbar__search">
    <input type="text" class="topbar__search-input" placeholder="Найти...">
    <button class="topbar__search-button">
      <svg version="1" viewBox="0 0 24 24" enable-background="new 0 0 24 24">
        <path d="M 9 2 C 5.1 2 2 5.1 2 9 C 2 12.9 5.1 16 9 16 C 10.722428 16 12.28779 15.386196 13.5 14.375 L 14 14.875 L 14 15.6875 L 20.3125 22 L 22 20.3125 L 15.6875 14 L 14.8125 14 L 14.34375 13.53125 C 15.372135 12.314388 16 10.738606 16 9 C 16 5.1 12.9 2 9 2 z M 9 4 C 11.8 4 14 6.2 14 9 C 14 11.8 11.8 14 9 14 C 6.2 14 4 11.8 4 9 C 4 6.2 6.2 4 9 4 z"></path>
      </svg>
    </button>
  </div>
  <label for="topbar__checked-search" class="topbar__button-open-search">
    <svg id="icon-serach-close" version="1" viewBox="0 0 24 24" enable-background="new 0 0 24 24">
      <path d="M 9 2 C 5.1 2 2 5.1 2 9 C 2 12.9 5.1 16 9 16 C 10.722428 16 12.28779 15.386196 13.5 14.375 L 14 14.875 L 14 15.6875 L 20.3125 22 L 22 20.3125 L 15.6875 14 L 14.8125 14 L 14.34375 13.53125 C 15.372135 12.314388 16 10.738606 16 9 C 16 5.1 12.9 2 9 2 z M 9 4 C 11.8 4 14 6.2 14 9 C 14 11.8 11.8 14 9 14 C 6.2 14 4 11.8 4 9 C 4 6.2 6.2 4 9 4 z"></path>
    </svg>
    <svg id="icon-serach-open" viewBox="0 0 32 32">
      <path style="text-indent:0;text-align:start;line-height:normal;text-transform:none;block-progression:tb;-inkscape-font-specification:Bitstream Vera Sans" d="M 8.71875 7.28125 L 7.28125 8.71875 L 14.5625 16 L 7.28125 23.28125 L 8.71875 24.71875 L 16 17.4375 L 23.28125 24.71875 L 24.71875 23.28125 L 17.4375 16 L 24.71875 8.71875 L 23.28125 7.28125 L 16 14.5625 L 8.71875 7.28125 z"
      color="#000" overflow="visible" font-family="Bitstream Vera Sans"></path>
    </svg>
  </label>
  <div class="topbar__search-panel">
    <div class="topbar__search-panel-list">
      <a href="#" class="topbar__search-panel-list-item">Обои для рабочего стола</a>
      <a href="#" class="topbar__search-panel-list-item">Новости</a>
      <a href="#" class="topbar__search-panel-list-item">StackOverflow</a>
    </div>
  </div>
</div>
<input type="checkbox" id="topbar__checked-leftmenu">
<div class="leftmenu">
  <ul class="leftmenu__list">
    <li><a href="#" class="leftmenu__list-item">Пункт 1</a>
    </li>
    <li><a href="#" class="leftmenu__list-item">Пункт 2</a>
    </li>
    <li><a href="#" class="leftmenu__list-item">Пункт 3</a>
    </li>
  </ul>
  <label for="topbar__checked-leftmenu" class="leftmenu__hidemenu"></label>
</div>

如果有人知道如何更好地实现这一点,我将很高兴学习:)

css
  • 3 个回答
  • 10 Views
Martin Hope
Alexandr_TT
Asked: 2020-01-14 19:26:52 +0000 UTC

单击时来回交换 SVG 元素颜色

  • 9

这个问题已经被问过很多次了,使用 有很好的解决方案javascript,比如这段代码:

var shapeClick = document.getElementById("shape").addEventListener("click", changeColor);
var clicks = 0;
function changeColor(){
  if (shape.style.fill == "rgb(29, 172, 249)")
  {
    shape.style.fill = "rgb(255, 0, 0)";
  }
  else {
    shape.style.fill = "rgb(29, 172, 249)";
  }
}
<div>  
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events"
 width="250" height="250" viewBox="0 0 250 250" 
> 
         <circle id="shape" class="seat" cx="120" cy="125" r="50" style="fill: #1dacf9" stroke="black" stroke-width="2" />>
 
   </svg> 
   </div>

一切正常,在脚本的帮助下你可以做很多事情。

注意问题

如何在SVG (SMIL)不使用javascriptand的情况下在 pure 上做同样的事情CSS。

只需在点击时更改颜色很容易:

<svg id="svg1" version="1.1" xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events"
 width="250" height="250" viewBox="0 0 250 250" 
> 
         <circle  cx="120" cy="125" r="50" style="fill: dodgerblue; stroke:black; stroke-width:2;" >
		 <animate attributeName="fill" from="dodgerblue" to="red" fill="freeze" begin="svg1.click" dur="0.1s" calcMode="discrete"/>
			 </circle>
	 
   </svg> 

但是我并没有想到如何通过反复点击对象来改变颜色。

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Vyacheslav Potseluyko
Asked: 2020-01-09 17:19:06 +0000 UTC

预处理器上的复杂多边形

  • 9

clip-path: polygon()需要特定点。下面代码中的某种示例。

.wrapper {
  width: 960px;
  height: 720px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background-image: url(http://beerhold.it/960/722);
  background-repeat: no-repeat;
  backgorund-position: center center;
  position: relative;
}

.key {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10em;
  height: 10em;
  border: 2em solid rgba(255, 255, 255, .3);
  border-radius: 10em;
}

.block1,
.block2 {
  position: absolute;
  top: 0;
  width: 480px;
  height: 720px;
}

.block1 {
  left: 0;
  background-color: rgba(255, 0, 0, .2);
}

.block2 {
  right: 0;
}
.block3 {
  top: 0;
  width: 100%;
  height: calc(50% - 7em);
  background: rgba(0, 0, 0, 0.7);
  
}
.block4 {
  top: calc(50% - 7em);
  background: rgba(0, 0, 0, 0.7);
  width: 100%;
  height: 14em;
  clip-path: polygon(1% 0%, 100% 0%, 100% 100%, 0% 100%, 8% 94%, 15% 88%, 22% 78%, 29% 69%, 34% 60%, 34% 48%, 33% 36%, 30% 22%, 23% 14%, 12% 7%);
}
.block5 {
  bottom: 0;
  height: calc(50% - 7em);
  width: 100%;
  background: rgba(0, 0, 0, 0.7);
}
<div class="wrapper">
  <div class="block1"></div>
  <div class="block2">
    <div class='block3'></div>
    <div class='block4'></div>
    <div class='block5'></div>
    <div class='block6'></div>
  </div>
  <div class="key"></div>
</div>

如您所见,此刻它只是一条曲线,凹进了图形。任务是画一个半圆(或尽可能接近它),凹入一个图形。在我的理解中,这需要less,sass依此类推。还有sin,cos。我不知道从哪里开始,如何开始,我没有遇到过。感谢@AndreyFedorov 在这里使用他的代码片段

(!) 我同意给出相同结果的任何其他选项。

在此处输入图像描述

svg
  • 1 个回答
  • 10 Views
上一页
下一页

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5