html - 六边形 Angular 上的文字

标签 html css geometry css-shapes

我有一个六边形,我想在它的每个 Angular 上写点东西。确切地说,我想从六边形的外部区域命名它的每个 Angular 。你可以在这个 jsfiddle 中看到代码.这是我现在拥有的:

HTML:

<div class="hexagon"><span>bla</span></div>

CSS:

.hexagon span {
  display: block;
  position: absolute;
  top:2.8867513459481287px;
  left: 0;
  width:290px;
  height:167.4316px;
  z-index: 2;
  background: inherit;
}

但是,这会将文本放置在六边形内部,而不是外部。有什么想法吗?

最佳答案

你可以在那里扔一个外部 div,并使用 absolutetransform 的组合,但我打赌 SVG 是理想的。

.outer span {
    position: absolute;
    z-index: 20;
}

.outer span:nth-of-type(1) {
    top: 3rem;
    left: 0;
    color: red;
    transform: rotate(-30deg);
}

.outer span:nth-of-type(2) {
    top: 0;
    left: 50%;
    transform: rotate(30deg) translate(.5rem, -1rem);
    color: green;
}

.outer span:nth-of-type(3) {
    top: 6rem;
    right: 0;
    transform: rotate(90deg) translate(1rem, -2rem);
}

.outer span:nth-of-type(4) {
    bottom: 0;
    left: 0;
}

.outer span:nth-of-type(5) {
    bottom: 0;
    left: 50%;
}

.outer span:nth-of-type(6) {
    bottom: 0;
    right: 0;
}

http://jsfiddle.net/sheriffderek/n6afyLjb/1/

关于html - 六边形 Angular 上的文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33598595/

相关文章:

javascript onblur() 不工作

html - 如何将两张 table 放在彼此的顶部,占用相同的宽度

php - 如何将特色内容放在商店内容下方

javascript - 如何创建在 Bootstrap 3 中也可以放大的响应图像

android - Cordova /Phonegap : Disable bounce only for header and footer

html - 两个按钮调整到网页

geometry - 如何判断两个凸多边形是否相交?

python - Matplotlib 使中心圆透明

javascript - 传单只呈现在一个 Angular 落

math - 在已知并固定相机型号时校正鱼眼失真