【问题标题】:how to set cleditor font for <p> or any other tag?如何为 <p> 或任何其他标签设置 cleditor 字体?
【发布时间】:2017-04-29 12:00:18
【问题描述】:

我想将 textarea 中的文本发布到另一个 html 页面。

但是当我将文本粘贴到textarea 时,字体和大小不符合我的风格! 我已经设置了 textarea&lt;p&gt; 字体大小和字体系列,但它没有帮助。

<textarea class="cleditor" id="textarea2"name="about" rows="3"></textarea>

    .cleditorMain {border:1px solid #ddd; padding:0 1px 1px; background-color:white}
    .cleditorMain iframe {border:none; margin:0; padding:0}
    .cleditorMain textarea {border:none; margin:0; padding:0; overflow-y:scroll; dir:rtl; font-family:Verdana,sans-serif;font-weight:normal;resize:none;outline:none /* webkit grip focus */}
    .cleditorToolbar {background: url('../img/toolbar.gif') repeat}
    .cleditorGroup {float:left; height:26px}
    .cleditorButton {float:left; width:24px; height:24px; margin:1px 0 1px 0;background: url('../img/buttons.gif')}
    .cleditorDisabled {opacity:0.3; filter:alpha(opacity=30)}
    .cleditorDivider {float:left; width:1px; height:23px; margin:1px 0 1px 0; background:#CCC}
    .cleditorPopup {border:solid 1px #999; background-color:white; position:absolute; font:10pt Arial,Verdana; cursor:default; z-index:10000}
    .cleditorList div {padding:2px 4px 2px 4px}
    .cleditorList p,
    .cleditorList h1,
    .cleditorList h2,
    .cleditorList h3,
    .cleditorList h4,
    .cleditorList h5,
    .cleditorList h6,
    .cleditorList font {padding:0; margin:0; background-color:Transparent}
    .cleditorColor {width:150px; padding:1px 0 0 1px}
    .cleditorColor div {float:left; width:14px; height:14px; margin:0 1px 1px 0}
    .cleditorPrompt {background-color:#F6F7F9; padding:4px; font-size:8.5pt}
    .cleditorPrompt input,
    .cleditorPrompt textarea {font:8.5pt Arial,Verdana;}
    .cleditorMsg {background-color:#FDFCEE; width:150px; padding:4px; font-size:8.5pt}

html代码

    <p class="about-p">
         {!! $about['about'] !!}
    </p>

css

.about-p{
     font-family: Verdana,sans-serif;
     font-weight:normal;
     text-align:justify;
}

【问题讨论】:

  • 请添加你的html,css代码,否则我们只能预测
  • 请阅读How do I ask a good question并相应地编辑您的问题,因为这将大大提高您获得好的答案的机会,并且不会让您的问题被否决或关闭。
  • 如果您想为所有tags 明确设置特定的font,那么您可以执行* { font-family: cursive !important;} 之类的操作。

标签: php jquery html css cleditor


【解决方案1】:

要仅选择一个元素、类名或 ID... 仅选择该元素:

textarea {
    font-family: Helvetica, Arial, sans-serif;
}

.font-normal {
    font-family: Georgia, serif;
}

您也可以用逗号分隔选择器以将一种字体分配给多个元素:

div, p, textarea, .font-sans-serif {
    font-family: Helvetica, Arial, sans-serif;
}

【讨论】:

    【解决方案2】:

    如果您使用 cleditor,请检查您是否添加了脚本和 css 文件。 there is a simple demo

    【讨论】:

      【解决方案3】:

      或者,您可以强制 CSS 遵循您的字体规范,只需在 textarea 属性后添加 !important 标签即可。 像这样

      textarea {font-family: Helvetica !important;}  
      

      以这种格式手动重写它们,将标签放在属性值之后应该会强制 CSS 自动赋予您的 CSS 规则更高的优先级。

      【讨论】:

        【解决方案4】:

        解决了!

            .cleditorList p{font-family:Verdana,sans-serif;!important; font-weight:normal;}
        

        样式应该添加到这一行。

        【讨论】:

          猜你喜欢
          • 2021-11-04
          • 2018-04-26
          • 1970-01-01
          • 1970-01-01
          • 2022-06-10
          • 2014-11-16
          • 2018-05-06
          • 1970-01-01
          • 2011-08-30
          相关资源
          最近更新 更多