自定义可调整大小的div

时间:2013-09-06 05:29:13

标签: html css

创建可调整大小的div(调整大小:两者都是CSS)后,我点击div的右下角后调整大小。在Firefox中,它看起来像: item to change

但我想在那里放置我的自定义图片,怎么做?

#resizeablediv {
    width:200px;
    height:200px;
    resize:both;
    background-color:black;
    overflow:auto;
}

DEMO

4 个答案:

答案 0 :(得分:0)

background: grey url(http://i.stack.imgur.com/Ckblr.png) no-repeat bottom right;

答案 1 :(得分:0)

这是由浏览器呈现的,并且这些样式无法通过CSS更改。请尝试将图像(自定义)放在右下角。

答案 2 :(得分:0)

所以我做了一些关于调整大小的研究。它是如此新颖,并不是每个主流浏览器都支持它。据我所知,现有的方法还没有重新定位这个元素。

以下是调整大小的规格页:

https://developer.mozilla.org/en-US/docs/Web/CSS/resize

所以你有两个选择,两个都不是完美的:

1)背景图片。这不会隐藏调整大小图标,但至少会遮挡它。

2)使用指针事件覆盖div以包含您的图像:无;适用于它。图标仍然存在,但它可以隐藏在包含图像的绝对定位的div下面。

.custom-image{
    background:pink; //you could set this background to your custom image.
    height:7px;
    width:7px;
    position:absolute;
    bottom:0px;
    right:0px;
    pointer-events: none;
}

我已经更新了你的小提琴来演示。 DEMO

答案 3 :(得分:0)

这是获取自定义按钮/图像的方法-将所需的内容放在div的右下角

.parent {
  border: none;
  cursor: pointer;
  display: inline-block;
  padding: 0;
  position: relative;
}

.parent:after {
  border: 3px solid cyan;
  border-radius: 50%;
  bottom: 0;
  box-shadow: inset 0 0 0 1px rgba(14, 19, 24, .15);
  box-sizing: border-box;
  content: " ";
  cursor: pointer;
  display: block;
  pointer-events: none;
  position: absolute;
  right: 0;
  height: 20px;
  width: 20px;
  animation: blink 2s infinite;
}

@keyframes blink {
  from,
  to {
    background: rgba(0, 255, 255, 0.5)
  }
  50% {
    background: transparent
  }
}

.child {
  background: salmon;
  cursor: pointer;
  height: 150px;
  width: 345px;
  min-width: 300px;
  min-height: 150px;
  max-height: 100vh;
  max-width: 100vw;
  opacity: 0;
  overflow: auto;
  pointer-events: none;
  resize: both;
  background: #444;
}

.content {
  padding: 20px;
  position: absolute;
  left: -7px;
  right: -7px;
  top: -7px;
  bottom: -7px;
  color: cyan;
  font-family: Arial;
  background: #444;
  letter-spacing: 2px;
  border-radius: 15px;
}
<div class='parent'>
  <div class="content">
    r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e r e s i z e a b l e
  </div>
  <div class="child"></div>
</div>

相关问题