小编Red*_*ant的帖子

CSS:得到一个div重叠的按钮,z-index不起作用

小提琴示例

任何人都可以弄清楚如何让按钮重叠,flyout-content以便隐藏按钮的右边框?我想得到这个效果:

在此输入图像描述

我已经尝试更改z-index内容和按钮,但它不起作用.

HTML

<div class='flyout'>
  <button class="flyout-toggle">Click</button>
  <div class="flyout-content"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.flyout-toggle {
    position: absolute;
    transform: rotate(90deg);
    top: 50%;
    left: -50px;
    z-index: 998;
    width: 85px;
    height: 35px;
    font-size: 13px;
    background: #92C7B8;
    border: solid #fff 1px;
}
.flyout-content {
    z-index:997
}
.flyout {
    position: fixed;
    z-index: 999;
    top: 0;
    right: 0;
    width: 15%;
    height: 100%;
    border-left: solid #fff 1px;
    background: #92C7B8;
    -webkit-box-shadow: 0px -5px 15px 0px #bfbfbf;
    box-shadow: 0px -5px 15px 0px #bfbfbf;
    transition: all .3s …
Run Code Online (Sandbox Code Playgroud)

html css z-index

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

在带有express.js和lodash/underscore的模板文件中包含一个页脚?

我有一个html文件footer.html存储网站的页脚,我想在不同的页面上重用它.如何template.html使用lodash/underscore 将其包含在模板文件中?我已阅读本文章有关node-partial,但我不知道怎么模块node-partial可以与工作render在快递4.

var express = require('express')
, app = express()
, http = require('http').createServer(app)
, _ = require('lodash')._
,cons = require('consolidate');

app.engine('html', cons.lodash);
app.set('view engine', 'html')
app.set('views', './views')

app.get('/', function(req, res){ 
   res.render('index.html', {hello: 'Welcome !'})
});
Run Code Online (Sandbox Code Playgroud)

Template file

<h1><%= hello %></h1>
<p><%= _('hello') %></p>
<% include './footer.html' %> // Can I add a footer file to the template?
Run Code Online (Sandbox Code Playgroud)

javascript node.js express underscore.js lodash

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

在WebStorm/PhpStorm中,使用Babel文件观察器定义的错误并未定义

我一直在按照本指南将ES6代码转换为PhpStorm中的ES5代码.

我的问题是当脚本有一个import语句时:

import TestingView from 'component/TestingView';
class ItemPage extends React.Component {
    render () {
        return <TestingView>
    }
}
Run Code Online (Sandbox Code Playgroud)

TestingView.js

export default class TestingView extends React.Component{
    render(){
        return <div>Hello!!!!</div>
    }
}
Run Code Online (Sandbox Code Playgroud)

文件监视器将其转换为以下形式:

'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return …
Run Code Online (Sandbox Code Playgroud)

javascript babel phpstorm webstorm ecmascript-6

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

通过Immutable.js中的特定键对有序映射进行排序

请检查这个小提琴示例

如何orderedMap通过键sequence按降序对对象进行排序?我知道有一种sortBy方法,但文件没有给出一个更清晰的例子.

这是我的原始对象:

var props = {
  "item": {
    "A": {
      "sequence": 5
    },
    "B": {
      "sequence": null
    },
    "C":{
      "sequence": 2
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我希望结果如下:

var props = {
  "item": {
    "A": {
      "sequence": 5
    },
    "C":{
      "sequence": 2
    },
    "B": {
      "sequence": null
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

示例代码:

var data = Immutable.fromJS(props,(key, value)=>{
     var isIndexed = Immutable.Iterable.isIndexed(value);
     return isIndexed ? value.toList() :value.toOrderedMap();
});

var sorted = data.get('item').sortBy((item) => item.get('sequence'));

console.log(sorted.toJS())
Run Code Online (Sandbox Code Playgroud)

javascript sorting immutable.js

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

在Dagger2中将依赖项注入后台服务

我有Shared Preferences一个匕首单身组件.我需要将它注入到后台服务中FirebaseInstanceService.这是我的尝试:

public class InstanceIDListenerService extends FirebaseInstanceIdService {
    @Inject
    Preferences preferences;

    @Override
    public void onTokenRefresh() {
        ((MyApp) getApplication()).getSingletonComponent().inject(this);
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        preferences.setFcmToken(refreshedToken);

    }
}
Run Code Online (Sandbox Code Playgroud)

它以这种方式使用:

   <service android:name="com.fcm.InstanceIDListenerService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
   </service>
Run Code Online (Sandbox Code Playgroud)

我应该((MyApp) getApplication()).getSingletonComponent().inject(this);onTokenRefresh听众中使用吗?这是注入依赖项的正确侦听器吗?

java android dagger-2

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

如何在 PreferenceFragment 中即时更新昼夜模式?

我见过一些这样的应用程序Pocket可以在设置中立即在白天和夜间模式之间切换而无需重新加载,但在我自己的示例中无法做到这一点:

public class SettingsActivity extends PreferenceActivity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment()).commit();
    }

    public static class PrefsFragment extends PreferenceFragment{
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            final Context context = getActivity();
            addPreferencesFromResource(R.xml.preferences);
            SwitchPreference dayNightSwitch = (SwitchPreference) findPreference(getString(R.string.pref_day_night_key));
            dayNightSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    boolean isNightMode = (boolean) newValue;    
                    AppCompatDelegate.setDefaultNightMode(isNightMode? AppCompatDelegate.MODE_NIGHT_YES:AppCompatDelegate.MODE_NIGHT_NO);
                    return true;
                }
            });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它看起来像AppCompatDelegate.setDefaultNightMode不工作PreferenceFragment,并PreferenceActivity在所有。有没有办法立即更新日夜模式?

java android android-fragments

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

如何使用变量用于图像文件夹路径

我可以在两个变量(Eg var path = css/image/var urlpath = /pic/funny/)中有一个图像文件夹路径和一个url路径,并分别在每个图像和url之前附加它们,这样我就不必为每个图像重复修补 var picData

Array.prototype.shuffle = function() {
                var s = [];
                while (this.length) s.push(this.splice(Math.random() * this.length, 1));
                while (s.length) this.push(s.pop());
                return this;
            }

            var picData = [
                ['img1','url_1'],
                ['img2','url_2'],
                ['img3','url_3'],
                ['img4','url_4'],
                ['img5','url_5'],
                ['img6','url_6'],
                ['img7','url_7']];

            picO = new Array();
            randIndex = new Array();  //array of random indexes
            for(i=0; i < picData.length; i++){
                picO[i] = new Image();
                picO[i].src = picData[i][0];
                picO[i].alt = picData[i][1];
                randIndex.push(i);
            }
            randIndex.shuffle();
            window.onload=function(){
                var mainImgs = document.getElementById('carouselh').getElementsByTagName('img'); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery var

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

在jQuery中将选择器作为函数参数传递

小提琴示例

我可以将$(this)选择器以外的选择器作为函数参数传递吗?

我的意思是我要传递的选择器(#AareaBarea)是我想要添加一些HTML内容的选择器.

function info(a){
  var source = $(this).data('source')
  $(a).html(source)
  console.log(source);
}

$('#one').click(info('#Aarea'))
$('#two').click(info('#Barea'))

<button data-source="AAA" id='one'>Button</button>
<div id="Aarea"></div>
<div id='Barea'></div>
<a href='#' data-source='BBB' id='two'>Click</a>
Run Code Online (Sandbox Code Playgroud)

但除非我不使用参数并在函数中指定那些选择器,否则它不起作用.

html javascript jquery

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

如何在PHP中创建平面JSON对象而不是对象数组

我试图用PHP中的三个数组创建一个平面JSON对象.以下代码的输出是包含对象数组的对象:

{
 "Amphibian":[
     {"Frogs":"Green"}
  ],
 "Mammal":[
    {"Bats":"Black"},
    {"Elephants":"Grey"},
    {"Rats":"Black"},
    {"Turtles":"Green"}
  ]
}
Run Code Online (Sandbox Code Playgroud)

但是,这不是我想要的.是否可以在循环期间将输出转换为包含扁平对象的对象?这是我想要的输出:

{
  "Amphibian":
    {"Frogs":"Green"},
  "Mammal":  
    {"Bats":"Black","Elephants":"Grey","Rats":"Black","Turtles":"Green"}
}
Run Code Online (Sandbox Code Playgroud)

这是代码:

$colors = array("Frogs"=>"Green","Bats"=>"Black","Elephants"=>"Grey","Rats"=>"Black","Turtles"=>"Green");

$allAnimals = array("Frogs","Bats","Elephants","Rats","Turtles");

$group = array("Frogs"=>"Amphibian","Bats"=>"Mammal");

$output = array();

foreach($allAnimals as $key=>$animal){

    if(isset($group[$animal])){

        $groupTitle = $group[$animal];
    }

    $output[$groupTitle][] = array($animal=>$colors[$animal]);

}

print JSON_encode($output);
Run Code Online (Sandbox Code Playgroud)

php json

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

在Elasticsearch中按照确切的顺序搜索多个值

我正在寻找一种方法来进行精确的数组匹配,其中项目必须按顺序排列.

示例文件:

{"id": 1, "categories" : ["A", "C","E"]}
{"id": 2, "categories" : ["A", "C"]}
{"id": 3, "categories" : ["C", "A"]}
Run Code Online (Sandbox Code Playgroud)

当我用"A"和"C"搜索时,它只返回第一个和第三个文件

{"id": 1, "categories" : ["A", "C","E"]}
{"id": 2, "categories" : ["A", "C"]}
Run Code Online (Sandbox Code Playgroud)

不应该返回第三个,因为订单不匹配.

我已经尝试了以下查询,但它仍将返回第三个文档,因为它没有考虑顺序:

{
    "sort": [
      {
        "modified": {
          "order": "desc"
        }
      }
    ],
    "query": {
      "bool": {
        "filter": {
          "bool": {
            "must": [
              {
                "term": {
                  "categories": "A"
                }
              },
              {
                "term": {
                  "categories": "C"
                }
              }
            ]
          }
        }
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

我有超过50个字段,我想提供这个确切的订单搜索选项,所以我不希望添加额外的字段服务作为类别关键字并查询"AC",{"id":1,"类别":["c ","d"],"categorieskey":"cd"}

这有什么其他方法吗?

lucene elasticsearch

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