html - CSS + 不同大小的文本区域以适应图像

标签 html css

http://jsfiddle.net/adamadam123/qv2yR/

以上是我目前正在使用的代码。下面是我要实现的目标的图片。

enter image description here

它基本上是一个聊天框“IM”,我有一个蓝色和粉红色的图像,需要能够在图像中放置不同数量的文本。

我也尝试过使用图像作为 CSS 背景,但发现它无法拉伸(stretch)以适合文本。还尝试了 float 和绝对定位。

如有任何帮助,我们将不胜感激。

谢谢

    <div class="chatMessengerBody">

        <div class="chatMessengerChatBubble chatMessengerChatBubbleBlueWrapper">
            <img src="images/chat-messenger-chat-bubble-blue.png" class="chatMessengerChatBubble chatMessengerChatBubbleBlue"/>
            <p class="chatMessengerChatBubbleContent">Great, thanks for asking. Never better to tell you the truth. So how about those dolphins?
            Great, thanks for asking. Never better to tell you the truth. So how about those dolphins?
            Great, thanks for asking. Never better to tell you the truth. So how about those dolphins?
            </p>
        </div>

        <div class="chatMessengerChatBubble chatMessengerChatBubblePinkWrapper">
            <img src="images/chat-messenger-chat-bubble-pink.png" class="chatMessengerChatBubble chatMessengerChatBubblePink"/>
            <p class="chatMessengerChatBubbleContent">Great, thanks for asking. Never better to tell you the truth. So how about those dolphins?</p>
        </div>

    </div>

最佳答案

http://jsfiddle.net/qv2yR/10/

CSS

.blue {
    background: #EBF7FF;
    border: 1px solid #D4F1FD;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    color :#6B95B0;
    margin-bottom: 5px;
    padding: 5px;    
    width: 200px;
}

.pink {
    background: #FFF8F2;
    border: 1px solid #FFEEE4;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    color :#D386A8;
    margin-bottom: 5px;
    padding: 5px;    
    width: 200px;
}

HTML

<div class="blue">
 this is the blue one
</div>

<div class="pink">
    this is the pink one.
</div>

关于html - CSS + 不同大小的文本区域以适应图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13351840/

相关文章:

jquery - 单击下拉菜单时 bootstrap3 导航关闭

html - 图像下的右对齐文本(无 javascript)

javascript - 如何为略有不同的不同版本的网络应用程序构建代码?

html - 链接到略高于网页特定部分的区域

html - 子菜单单击不适用于操作

html - 图片旁边的垂直对齐按钮

javascript - 我如何对我的数据关闭 ="modal"产生两种效果;一个重新加载父页面,而另一个不加载

javascript - 如何在三星电视模拟器上打开新屏幕?

php - 如何即时缩小CSS?

css - 设置 Ionic 警报弹出元素的默认样式