gpt4 book ai didi

html - Elm中段落的宽度

转载 作者:行者123 更新时间:2023-11-28 04:17:43 24 4
gpt4 key购买 nike

试图使段落具有一定的宽度,但段落超出了。为什么 Elm 不理我?

那个宽度必须是一个整数,所以我给了它以像素为单位的宽度。

import Html exposing (..)
import Html.Attributes exposing (..)


info : String
info = "Ports must be careful about what values are allowed through. Elm is statically typed, so each port is fitted with some border protection code that ensures that type errors are kept out. Ports also do some conversions so that you get nice colloquial data structures in both Elm and JS."

main = p [ Html.Attributes.width 500] [ text info ]

Elm-Reactor 只是将其编译为 <p> ... </p>没有属性。

最佳答案

使用 Html.Attributes 中的“样式”

style [ ("width", "100px") ]

根据文档,“Html.Attributes.width”函数不适用于段落。

width : Int -> Attribute msg

Declare the width of a canvas, embed, iframe, img, input, object, or video.

http://package.elm-lang.org/packages/elm-lang/html/1.0.0/Html-Attributes#width

关于html - Elm中段落的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37638344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com