小编use*_*906的帖子

在使用javascript(d3库)加载之前从CSV中选择数据

我想在使用javascript(使用d3库)加载之前从CSV文件中选择一些数据.

这是我加载CSV的方式:

d3.csv("data.csv", function(csv) {
    vis.datum(csv).call(chart);
        });
Run Code Online (Sandbox Code Playgroud)

这是CSV文件的示例:

Class,Age,Sex,Survived
First Class,Adult,Male,Survived
First Class,Adult,Male,Survived
First Class,Adult,Male,Survived
First Class,Adult,Male,Survived
First Class,Adult,Male,Survived
First Class,Adult,Female,Survived
First Class,Adult,Female,Survived
First Class,Adult,Female,Survived
Second Class,Adult,Male,Perished
Second Class,Adult,Male,Perished
Second Class,Adult,Male,Perished
Third Class,Adult,Male,Survived
Third Class,Adult,Male,Survived
Third Class,Adult,Male,Survived
Third Class,Adult,Male,Survived
Third Class,Adult,Male,Perished
Third Class,Adult,Male,Perished
Crew,Adult,Male,Perished
Crew,Adult,Male,Perished
Crew,Adult,Female,Survived
Crew,Adult,Female,Survived
Run Code Online (Sandbox Code Playgroud)

例如,我只想在加载之前选择Second ClassFirst Classd3.csv.

我知道我可以删除CSV中的其他行,但我想创建一个函数,以便用户可以选择他想要使用的类别.我希望这是有道理的.

javascript csv d3.js

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

是否可以在按钮上使用:after伪元素?

我有一个按钮,在悬停时我想要一个after元素来显示.但我看不到它.是否可以在按钮上有一个:after元素?

HTML:

<button class="button button-primary">My button</button>
Run Code Online (Sandbox Code Playgroud)

CSS:

.button {
  cursor: pointer;
  height: 30px;
}

.button-primary {
  border: none;
}
.button-primary:hover:after {
  display: block;
  position: relative;
  top: 3px;
  right: 3px;
  width: 100px;
  height: 5px;
}
Run Code Online (Sandbox Code Playgroud)

html css pseudo-element

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

php重定向到带有消息的页面

我想重定向到一个页面,然后显示一条消息:

我拥有的是:

if (mysqli_affected_rows($link) == 1) 
{
   //succes         
    $message = 'succes';
    redirect_to('index.php');
}
Run Code Online (Sandbox Code Playgroud)

在索引页面上我有:

if (!empty($message)) {
    echo '<p class="message"> '.$message.'</p>';
}
Run Code Online (Sandbox Code Playgroud)

重定向功能正常工作:

function redirect_to( $location = NULL ) {
        if ($location != NULL) {
            header("Location: {$location}");
            exit;
        }
    }
Run Code Online (Sandbox Code Playgroud)

但它不会显示我的信息.它是空的.

php redirect message

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

用边框制作切角

我想在html中创建一个具有切角并且在形状周围有边框的形状.

我可以制作没有边框的截断形状,如下所示:

HTML:

<div class="cut-off"></div>
Run Code Online (Sandbox Code Playgroud)

CSS:

 .cut-off{
   position:relative;
   top:400px;
   left:400px;
   height:155px;
   width:200px;
   background:red;
}
.cut-off:after{
   position:absolute;
   bottom:0px; right:-20px;
   content:".";
   text-indent:-999px; overflow:hidden;
   display:block;
   width:0px; height:0px;
   border-top: 20px solid green;
   border-right: 20px solid transparent;
}
.cut-off:before{
   position:absolute;
   top:0; right:-20px;
   content:"#";
   text-indent:-999px; overflow:hidden;
   display:block;
   background:blue;
   width:20px; height:135px;
} 
Run Code Online (Sandbox Code Playgroud)

Jfiddle在这里

现在我想要一个围绕形状的边框.我该怎么做?

我想要一个像这样的形状:

形状

充满了色彩.

html css shape css3 css-shapes

8
推荐指数
1
解决办法
3784
查看次数

隐藏H1标签中的文本但不隐藏图像

我需要隐藏H1标签内的文本.但不是形象.问题是我只能改变CSS而不是html

<h1>
<img src="img/headerimg.png" width="900" height="125"/>
Header 1 text
</h1>
Run Code Online (Sandbox Code Playgroud)

有没有办法只用css隐藏"标题1文本"?我正在为大客户端做这个,他们只给我访问css文件.

html css hide

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

在多维数组中搜索值并在PHP中获取父数组

我有这个数组:

Array
(
    [0] => Array
        (
            [name] => Dick Jansen
            [matchedMovie] => Array
                (
                    [0] => Array
                        (
                            [nameMovie] => Saw
                            [genre] => Horror
                            [patheMovie] => Texas Chainsaw 3D
                            [patheMovieGenre] => Horror
                            [score] => 100.00
                        )

                )

        )

    [1] => Array
        (
            [name] => Jim Scott
            [matchedMovie] => Array
                (
                    [0] => Array
                        (
                            [nameMovie] => Shooter
                            [genre] => Action, Thriller
                            [patheMovie] => The Shining
                            [patheMovieGenre] => Horror, Suspense/Thriller 
                            [score] => 52.38
                        )

                    [1] => Array
                        (
                            [nameMovie] => …
Run Code Online (Sandbox Code Playgroud)

php arrays search multidimensional-array

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

使用jQuery设置HTML5音频的属性量不起作用

我试图用jQuery设置音频元素的音量.

<audio class="audio" autoplay="autoplay" controls="controls" src="All_Right.mp3"></audio>
Run Code Online (Sandbox Code Playgroud)

所以我选择音频标签并设置音量如下:

$('.audio').prop(volume, 0.1);
Run Code Online (Sandbox Code Playgroud)

但我得到了未捕获的参考错误: volume is not defined

我的代码出了什么问题?

audio jquery html5

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

Vue:在自定义复选框组件中与 v-model 绑定不起作用

我正在尝试构建一个自定义复选框组件,其中包含使用 v-for 循环从具有选项和值的数组生成的选项。如何将 v-model 正确绑定到复选框组件以使其正确更新?

现在的问题是模型只更新到最新选中的复选框,并没有给出包含所有选中选项的数组。

Vue.component('ui-checkbox', {
	 props: {   
    label: {
      type: String,
      required: true,
    },
    index: {
      type: Number
    },
    inputValue: {
      type: String
    }
  },
  methods: {
    onChange(e) {
      this.$emit('input', e.target.value);
    },
  },
	template: `<div>
    <input 
      :id="index"
      type="checkbox"
      :value="inputValue"
      @change="onChange" />
    <label :for="index">
      {{ label }}
    </label>
  </div>`,
})

new Vue({
  el: "#app",
  data: {
    checkOptions: [
      {
        label: 'Option 1',
        value: 'value of option 1',
      },
      {
        label: 'Option 2',
        value: 'value of option 2',
      }, …
Run Code Online (Sandbox Code Playgroud)

checkbox vue.js vuejs2 v-model

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

从中心裁剪并在 PHP 中调整大小(函数)

我想要一个功能,可以在不丢失纵横比的情况下调整图像的特定高度和重量。所以首先我想裁剪它然后调整它的大小。

这是我到目前为止得到的:

function image_resize($src, $dst, $width, $height, $crop=1){

  if(!list($w, $h) = getimagesize($src)) return "Unsupported picture type!";

  $type = strtolower(substr(strrchr($src,"."),1));
  if($type == 'jpeg') $type = 'jpg';
  switch($type){
    case 'bmp': $img = imagecreatefromwbmp($src); break;
    case 'gif': $img = imagecreatefromgif($src); break;
    case 'jpg': $img = imagecreatefromjpeg($src); break;
    case 'png': $img = imagecreatefrompng($src); break;
    default : return "Unsupported picture type!";
  }

  // resize
    $originalW = $w;
    $originalH = $h;

  if($crop){
    if($w < $width or $h < $height) return "Picture is too small!";
    $ratio = …
Run Code Online (Sandbox Code Playgroud)

php image function crop image-resizing

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

将多个fileupload与PHP中的复选框相关联

我想在上传文件并在PHP中检查相关复选框时执行某些操作,如何将文件输入类型与复选框链接?

这就是我所拥有的:

<input type="file" name="file_upload[]"  /> <input type="checkbox" name="checkbox[]"> linked to file-upload 1 <br/>
<input type="file" name="file_upload[]"  /> <input type="checkbox" name="checkbox[]"> linked to file-upload 2 <br/>
<input type="file" name="file_upload[]"  /> <input type="checkbox" name="checkbox[]"> linked to file-upload 3 <br/>
<input type="file" name="file_upload[]"  /> <input type="checkbox" name="checkbox[]"> linked to file-upload 4 <br/>
Run Code Online (Sandbox Code Playgroud)

php checkbox file-upload

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