小编ele*_*aar的帖子

中心图像成图

除了一个问题,我还有一个问题,但我找不到解决方案。

我有这个HTML:

 <section class="section" id="section-2">

        <div class="wrapper" id="wrapper">

            <div class="slider-container" id="slider-container">

                <figure class="panel-image">
                    <img src="imgs/projects/3d-particles-image.png">
                </figure>

                <figure class="panel-image">
                    <img src="imgs/projects/3d-particles-image.png">
                </figure>

            </div>

        </div>

    </section>
Run Code Online (Sandbox Code Playgroud)

而这个CSS:

.wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.slider-container {
    position: absolute;
    width: 100%;
    height: 100%;
}

.panel-image {
    position: absolute;
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 100%;
}

.panel-image > img { ????????? }
Run Code Online (Sandbox Code Playgroud)

我需要将img放置在图中,但“ panel-image”的位置必须是绝对的。有什么建议么?

非常感谢!

html css

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

Canvas isPointInPath()具有多个路径

我有一个名为Box的画布"对象",当鼠标悬停在它上面时我需要检测.

我有一个这个对象的draw()方法,我使用isPointInPath()方法,但只有当光标在最后一个路径上时才会改变.有什么建议?

Box.prototype.draw = function() {

    this.ctx.beginPath();
    this.ctx.moveTo(this.matrix.p1.x, this.matrix.p1.y);
    this.ctx.lineTo(this.matrix.p2.x, this.matrix.p2.y);
    this.ctx.lineTo(this.matrix.p3.x, this.matrix.p3.y);
    this.ctx.lineTo(this.matrix.p4.x, this.matrix.p4.y);
    this.ctx.lineTo(this.matrix.p1.x, this.matrix.p1.y);
    this.ctx.closePath();

    this.ctx.fillStyle = 'rgba(255, 255, 255, 0.1)';
    this.ctx.fill();

    if (this.ctx.isPointInPath(mouse.x, mouse.y)) {
        this.canvas.style.cursor = 'pointer';
        this.ctx.fillStyle = 'rgba(0, 0, 255, 0.5)';
        this.ctx.fill();
        return;
    }

    this.canvas.style.cursor = 'default';

};
Run Code Online (Sandbox Code Playgroud)

javascript html5 canvas

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

标签 统计

canvas ×1

css ×1

html ×1

html5 ×1

javascript ×1