亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

python 制作的下拉菜單可以在 HTML / CSS 中編輯嗎?

python 制作的下拉菜單可以在 HTML / CSS 中編輯嗎?

慕的地8271018 2023-10-24 19:49:17
所以基本上我使用這種方法創建了一個下拉菜單:控制器:        all_useroptions = []        for opt in db().select(db.useroptions.ALL):            all_useroptions.append(OPTION(opt.symbol, _value=opt.id))        opt_sel = SELECT(*all_useroptions, _name='opt_id', value=request.vars.opt_id)HTML: {{=opt_sel}}是否可以編輯菜單的“下拉”部分?我可以使用 CSS 編輯菜單的“按鈕”:        #opt_id {        color: rgb(105,105,105);        padding: 10px 10px;        text-align: center;        border-radius: 5px;        display: inline-block;        font-size: 20px;        margin: 10px 5px;        cursor: pointer;        position: relative;        min-width: 160px;        }但這只會改變按鈕,不會改變我的菜單。我想通過更改菜單的形狀、顏色和高度并在選項之間添加一些文本來使菜單“更漂亮”。有人知道該怎么做嗎?
查看完整描述

2 回答

?
開心每一天1111

TA貢獻1836條經驗 獲得超13個贊

在輸出到頁面的最終 HTML 中(檢查 python 腳本生成的頁面以查找其內容),您可以添加自定義 js 片段以進一步修改 HTML,根據初始代碼輸出動態修改元素。


? ? ...template code above that contains yours {{=opt_sel}}...


? ? <!-- javascript snippet you add at bottom of page to change html above -->

? ? <script>

? ? ? ?document.querySelectorAll(".classOnABunchOfElementsMadeByOptSel > li").style.background = "red";

? ? ? ?document.querySelector("#secondElementMadeByOptSel").style.margin = "20px";


? ? </script>

查看完整回答
反對 回復 2023-10-24
?
暮色呼如

TA貢獻1853條經驗 獲得超9個贊

只需將 _class 添加到 OPTION helper 參數列表中:


all_useroptions = []

for opt in db().select(db.useroptions.ALL):

? ? all_useroptions.append(OPTION(opt.symbol, _value=opt.id, _class='prettier'))

opt_sel = SELECT(*all_useroptions, _name='opt_id', value=request.vars.opt_id)

并根據您的喜好創建一個“更漂亮”的 CSS 定義

? ? *Named arguments that start with an underscore are interpreted as HTML tag attributes (without the underscore)*



查看完整回答
反對 回復 2023-10-24
  • 2 回答
  • 0 關注
  • 139 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號