【问题标题】:Text content of a div skip the line in adaptive card. - BotFrameworkdiv 的文本内容跳过自适应卡片中的行。 - 机器人框架
【发布时间】:2018-06-25 15:15:49
【问题描述】:

我正在尝试更改 botframework 的网络聊天外观。 展示自适应卡片时,它们超出了 div:

我希望带有“ac-pushButton”类的按钮元素中的文本内容跳过一行。不超过 div。

以下是自适应卡片的html和css代码:

div {
    display: block;
}


.wc-message-from-bot {
  float: left;
  margin-left: 8px; }

.wc-message-from-bot .wc-message-content {
  background-color: #eceff1;
  color: #000000; }

.wc-message-from-bot .wc-message-content {
    background-color: #eceff1;
    color: #000000;
}

/* list */
.wc-list > .wc-card {
  margin-top: 8px; }

.wc-list > .wc-card:first-child {
  margin-top: 0; }

/* alternate chat sizes */
.wc-message {
  max-width: 91%; }

.wc-card {
  border: 1px solid #d2dde5;
  width: 302px; }

.wc-adaptive-card {
  width: 318px; }

.wc-wide .wc-card {
  border: 1px solid #d2dde5;
  width: 398px; }

.wc-wide .wc-adaptive-card {
  width: 414px; }

.wc-narrow .wc-card {
  border: 1px solid #d2dde5;
  width: 198px; }

.wc-narrow .wc-adaptive-card {
  width: 214px; }

/* adaptive card adjustments from wc-card */
.wc-adaptive-card p {
  margin-left: 0;
  margin-right: 0; }

.wc-message-content {
    border-radius: 2px;
    box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2);
    padding: 8px;
    word-break: break-word;
}
<div class="wc-list">
    <div class="wc-card wc-adaptive-card hero">
        <div class="ac-container" style="background-color: rgba(0, 0, 0, 0); padding: 8px; box-sizing: border-box;">
            <div class="ac-container" style="background-color: rgba(0, 0, 0, 0); padding: 0px; box-sizing: border-box;"></div>
            <div style="height: 8px;"></div>
            <div>
                <div style="overflow: hidden;">
                    <div style="display: flex; flex-direction: column; align-items: flex-start;"><button type="button" class="ac-pushButton" style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 0 1 auto;">O que encontro na p&amp;#225;gina Meu Perfil?</button>
                        <div style="height: 8px;"></div>
                        
                        <button type="button" class="ac-pushButton" style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 0 1 auto;">O que &amp;#233; o Minha Carteira na p&amp;#225;gina Meu Perfil?</button>
                        <div style="height: 8px;"></div><button type="button" class="ac-pushButton" style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 0 1 auto;">O que &amp;#233; Meu Endere&amp;#231;o na p&amp;#225;gina Meu Perfil?</button>
                        <div style="height: 8px;"></div><button type="button" class="ac-pushButton" style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 0 1 auto;">None of the above.</button></div>
                </div>
                <div style="background-color: rgba(0, 0, 0, 0);"></div>
            </div>
        </div>
    </div>
</div>

我设法做的是这样:

Sub:将宽度从 wc-adaptive-card 类更改为自动。

但我希望他提供全文。

注意:我是初学者。

【问题讨论】:

  • 将按钮样式更改为:溢出:可见;文本溢出:初始;

标签: javascript html css botframework


【解决方案1】:

我相信以下方法可以解决您的问题。我删除了导致问题的不必要的内联样式,尤其是 overflow: hidden

如果它适合你,请告诉我。

.ac-pushButton {
  text-align: left;
  height: auto;
  max-width: 100%;
}

div {
  display: block;
}

.wc-message-from-bot {
  float: left;
  margin-left: 8px;
}

.wc-message-from-bot .wc-message-content {
  background-color: #eceff1;
  color: #000000;
}

.wc-message-from-bot .wc-message-content {
  background-color: #eceff1;
  color: #000000;
}


/* list */

.wc-list>.wc-card {
  margin-top: 8px;
}

.wc-list>.wc-card:first-child {
  margin-top: 0;
}


/* alternate chat sizes */

.wc-message {
  max-width: 91%;
}

.wc-card {
  border: 1px solid #d2dde5;
  width: 302px;
}

.wc-adaptive-card {
  width: 318px;
}

.wc-wide .wc-card {
  border: 1px solid #d2dde5;
  width: 398px;
}

.wc-wide .wc-adaptive-card {
  width: 414px;
}

.wc-narrow .wc-card {
  border: 1px solid #d2dde5;
  width: 198px;
}

.wc-narrow .wc-adaptive-card {
  width: 214px;
}


/* adaptive card adjustments from wc-card */

.wc-adaptive-card p {
  margin-left: 0;
  margin-right: 0;
}

.wc-message-content {
  border-radius: 2px;
  box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2);
  padding: 8px;
  word-break: break-word;
}
<div class="wc-list">
  <div class="wc-card wc-adaptive-card hero">
    <div class="ac-container" style="background-color: rgba(0, 0, 0, 0); padding: 8px; box-sizing: border-box;">
      <div class="ac-container" style="background-color: rgba(0, 0, 0, 0); padding: 0px; box-sizing: border-box;"></div>
      <div style="height: 8px;"></div>
      <div>
        <div style="overflow: hidden;">
          <div style="display: flex; flex-direction: column; align-items: flex-start;">
            <button type="button" class="ac-pushButton">
            O que encontro na p&amp;#225;gina Meu Perfil?
          </button>
            <div style="height: 8px;"></div>
            <button type="button" class="ac-pushButton">
              O que &amp;#233; o Minha Carteira na p&amp;#225;gina Meu Perfil?</button>
            <div style="height: 8px;">
            </div>
            <button type="button" class="ac-pushButton">
              O que &amp;#233; Meu Endere&amp;#231;o na p&amp;#225;gina Meu Perfil?
            </button>
            <div style="height: 8px;">
            </div>
            <button type="button" class="ac-pushButton">
              None of the above.
            </button>
          </div>
        </div>
        <div style="background-color: rgba(0, 0, 0, 0);"></div>
      </div>
    </div>
  </div>
</div>

【讨论】:

  • 感谢您的回复,但仍然没有完全解决问题。 ibb.co/jmS4c8
  • 我注意到您只是在按钮元素的顶部添加了样式,对吧?!
  • 是的,我为按钮添加了 CSS。 .ac-pushButton { text-align: left; height: auto; max-width: 100%; }。这确保它们不会扩展超过 100% 的父级宽度。请将代码复制到您的项目并检查它,因为正如您在 sn-p 中看到的那样,它工作得很好。
  • @RafaelOliveira:请让我知道我的解决方案是否适合您,如果适合,请将我的答案标记为已接受。 :)。
  • 那我不知道你想要达到什么结果。如果我的 sn-p 没有显示出想要的结果,请告诉我你想要得到什么。
【解决方案2】:

我可以通过添加以下内容来解决这里问题:

.ac-pushButton {
       white-space: normal;
}
.wc-adaptive-card {
       width: auto; 
}

【讨论】:

  • @StevenG。两天后我才能接受我的回答,对吧?
  • 啊,你是对的,我的错! [self-answer]
猜你喜欢
  • 2017-10-18
  • 2021-05-01
  • 2020-03-01
  • 2019-08-26
  • 2019-12-02
  • 2020-09-28
  • 1970-01-01
  • 2021-02-08
  • 2020-08-02
相关资源
最近更新 更多