2017-10-04 73 views
1

我想创建低于此图像的CSS/HTML版本,努力使每一个六边形打开一个弹出来形容我用Hexagon Generator被点击项目的内容六边形里面

可点击元素图像创造我的元素,但根据这张图片,我无法设法按照他们应该或者类似的方式排列他们。 (主要图像在中间,六边形在它周围)

并使整个事情响应(移动就绪),这是另一个问题。

enter image description here

+0

可能用css重现那个图像会很困难,我想你需要改变这个概念并使用canvas,看看这个库:http://fabricjs.com/有很多像fabric.js – Kalamarico

+0

做的你有任何工作代码,你可以放在一个片段?我认为你仍然可以用html/css来做到这一点。第一遍可能是用绝对定位将所有东西都敲击到位。 *编辑,虽然连接到中心和弹出的线肯定看起来更多,他们需要一个画布/ JS解决方案* – worc

+0

其实不,我没有任何有用的东西,我知道我会需要一些JS的弹出窗口,这对我来说很好,我仍然坚持要为图片周围的元素做些什么。 – tinyCoder

回答

6

这是没有办法优化的解决方案,我大概可以创造的东西好多了,但是我想让你看看的可以做到这一点的方法之一。

HTML

<div class="hex"> 
    <div class="hex-title"> 
    Simple title 
    </div> 
    <div class="hex-hide"></div> 
    <div class="hex-img"> 
    <img src="https://cdn.stocksnap.io/img-thumbs/960w/Q7STENMU1K.jpg"> 
    </div> 
</div> 

CSS

.hex{ 
    width:300px; 
    height:300px; 
    margin:50px auto; 
    position:relative; 
} 
.hex:before{ 
    content:""; 
    position:absolute; 
    width:0;height:0; 
    border:80px solid transparent; 
    border-top:0px solid #fff; 
    border-left:145px solid #fff; 
    top:0; 
    left:0; 
    z-index:9999; 
} 
.hex:after{ 
    content:""; 
    position:absolute; 
    width:0;height:0; 
    border:80px solid transparent; 
    border-top:0px solid #fff; 
    border-right:145px solid #fff; 
    top:0; 
    right:0; 
    z-index:9999; 
} 
.hex-title{ 
    width:105%; 
    height:40px; 
    background:#005A87; 
    position:absolute; 
    margin:auto; 
    left:-2.5%;top:0;bottom:0; 
    z-index:99999999999; 
    font-family:Arial; 
    font-size:14px; 
    color:#fff; 
    line-height:40px; 
    text-align:center; 
    text-transform:uppercase; 
    letter-spacing:2px; 
} 
.hex-img{ 
    width:100%; 
    height:100%; 
    position:relative; 
    overflow:hidden; 
} 
.hex-img img{ 
    max-height:100%; 
} 
.hex-hide{ 
    width:100%; 
    height:100%; 
    position:absolute; 
    top:0;left:0; 
} 
.hex-hide:before{ 
    content:""; 
    position:absolute; 
    width:0;height:0; 
    border:80px solid transparent; 
    border-bottom:0px solid #fff; 
    border-left:145px solid #fff; 
    bottom:0; 
    left:0; 
    z-index:9999; 
} 
.hex-hide:after{ 
    content:""; 
    position:absolute; 
    width:0;height:0; 
    border:80px solid transparent; 
    border-bottom:0px solid #fff; 
    border-right:145px solid #fff; 
    bottom:0; 
    right:0; 
    z-index:9999; 
} 

演示:https://jsfiddle.net/j74padnq/

这是类似于被张贴,尽管较少的细节图像演示:https://jsfiddle.net/j74padnq/1/

+0

感谢你的不错的工作,我已经创建了不错的单一六边形,但我的主要问题是以它们出现在上面的图像中的方式排序,或者类似的我不介意,我只需要解释药物的内容在一个很好的方式:( – tinyCoder

+0

@tinyCoder让我知道,如果你想我添加一些东西!创建这个4点左右之前,我去睡觉,所以我没有给它多少想法,但我会更多这个赏金非常诱人lol –

+0

男人,你做了什么真棒!!作为一个单一的六边形,它看起来非常棒,但我仍然试图在药物图像周围创建多个六边形,明白了我的意思吗? – tinyCoder