打开/关闭菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Module:StyledHeader:修订间差异

来自LCD wiki
创建页面,内容为“local p = {} function p.customStyles(frame) local args = frame:getParent().args local bgcolor = args['bgcolor'] or 'transparent' local border_width = args['border-width'] or '0' local color = args['color'] or 'transparent' local header = args['header'] or 'h1' local text = args['text'] or '' local underline_width = args['underline-width'] or '0' local padding_left = border_width ~= '0' and '10px' or '0px' local styles = str…”
 
无编辑摘要
 
(未显示同一用户的3个中间版本)
第4行: 第4行:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local bgcolor = args['bgcolor'] or 'transparent'
     local bgcolor = args['bgcolor'] or 'transparent'
     local border_width = args['border-width'] or '0'
     local border_left = args['border-left'] or '0'
     local color = args['color'] or 'transparent'
     local color = args['color'] or 'black'
     local header = args['header'] or 'h1'
     local header = args['header'] or 'h1'
     local text = args['text'] or ''
     local text = args['text'] or ''
     local underline_width = args['underline-width'] or '0'
     local border_bottom = args['border-bottom'] or '0'
     local padding_left = border_width ~= '0' and '10px' or '0px'
     local padding_left = border_left ~= '0' and '10px' or '0px'
 
    local styles = string.format(
        'background-color: %s; border-left: %s solid %s; padding-left: %s; margin-bottom: 5px;',
        bgcolor, border_width, color, padding_left
    )


     local header_styles = string.format(
     local header_styles = string.format(
         'margin: 0; color: %s; border-bottom: %s;',
         'background-color: %s; border-left: %s solid %s; padding-left: %s; margin-bottom: 10px; color: %s; border-bottom: %s;',
         color, underline_width ~= '0' and underline_width .. ' solid ' .. color or 'none'
         bgcolor, border_left, color, padding_left, color, border_bottom ~= '0' and border_bottom .. ' solid ' .. color or 'none'
     )
     )


     return string.format(
     return string.format(
         '<div style="%s"><%s style="%s">%s</%s></div>',
         '<%s style="%s">%s</%s>',
         styles, header, header_styles, text, header
         header, header_styles, text, header
     )
     )
end
end


return p
return p

2024年7月24日 (三) 15:59的最新版本

此模块的文档可以在Module:StyledHeader/doc创建

local p = {}

function p.customStyles(frame)
    local args = frame:getParent().args
    local bgcolor = args['bgcolor'] or 'transparent'
    local border_left = args['border-left'] or '0'
    local color = args['color'] or 'black'
    local header = args['header'] or 'h1'
    local text = args['text'] or ''
    local border_bottom = args['border-bottom'] or '0'
    local padding_left = border_left ~= '0' and '10px' or '0px'

    local header_styles = string.format(
        'background-color: %s; border-left: %s solid %s; padding-left: %s; margin-bottom: 10px; color: %s; border-bottom: %s;',
        bgcolor, border_left, color, padding_left, color, border_bottom ~= '0' and border_bottom .. ' solid ' .. color or 'none'
    )

    return string.format(
        '<%s style="%s">%s</%s>',
        header, header_styles, text, header
    )
end

return p