我试图将按钮的文本垂直和水平居中对齐,默认情况下不存在。我尝试使用“偏移”来定位按钮中的文本,但在各种设备尺寸上定位并不一致。
我的按钮的代码是:
Button(
onClick = {
navController.navigate("fourth_screen")
},
modifier = Modifier.constrainAs(buttonSave) {
top.linkTo(glButtonSaveTop)
bottom.linkTo(glButtonSaveBottom)
start.linkTo(glLeft)
end.linkTo(glRight)
width = Dimension.fillToConstraints
height = Dimension.fillToConstraints
},
enabled = !errorMsg.value,
colors = if (query.value.text != ""){
ButtonDefaults.
buttonColors(backgroundColor = colorResource(id = R.color.voodlee_red))}
else {
ButtonDefaults.
buttonColors(backgroundColor = colorResource(id = R.color.gray))}
) {
Text(
"Save", color = colorResource(id = R.color.dark_blue),
fontSize = with(LocalDensity.current) {
dimensionResource(id = R.dimen._16ssp).toSp()
},
fontFamily = FontFamily(Font(R.font.poppins_medium)),
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxSize().offset(y= (0.15).dp)) //offset for positioning
}
Run Code Online (Sandbox Code Playgroud)
如何使按钮中的文本垂直和水平居中,以适应所有设备尺寸。
编辑:在稳定的 Jetpack …
我想对开关选项卡进行编程(使用 bootstrap 5)。Bootsrap 文档说:
作为最佳实践,我们建议使用选项卡元素,因为这些是触发动态更改的控件,而不是导航到新页面或位置的链接。
所以我想使用按钮而不是链接。代码:
$("#mybut").click(function() {
var sel = document.querySelector('#nav-tab-manager')
bootstrap.Tab.getInstance(sel).show()
})Run Code Online (Sandbox Code Playgroud)
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-tabs-order" data-bs-toggle="tab" data-bs-target="#tabs-1" type="button" role="tab" aria-controls="tabs-1" aria-selected="true">Orders
</button>
<button class="nav-link" id="nav-tab-manager" data-bs-toggle="tab" data-bs-target="#tabs-2" type="button" role="tab" aria-controls="tabs-2" aria-selected="false">Managers
</button>
</div>
</nav>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="tabs-1" role="tabpanel" aria-labelledby="tabs-tab1">
Orders
</div>
<div class="tab-pane fade" id="tabs-2" role="tabpanel" aria-labelledby="tabs-2">
Managers
</div>
</div>
<button type="button" class="btn btn-primary" id="mybut">Want switch to manager</button> …Run Code Online (Sandbox Code Playgroud)如何使用discord-buttons、discord.js 将超过 5 个按钮附加到消息中?
\n\n我尝试的方式:
\nlet Buttons = [];\n Buttons[0] = new discordButton.MessageButton().setStyle(\'gray\').setID("0").setLabel(\' \');\n Buttons[1] = new discordButton.MessageButton().setStyle(\'gray\').setID("1").setLabel(\' \');\n Buttons[2] = new discordButton.MessageButton().setStyle(\'gray\').setID("2").setLabel(\' \');\n\n Buttons[3] = new discordButton.MessageButton().setStyle(\'gray\').setID("3").setLabel(\' \');\n Buttons[4] = new discordButton.MessageButton().setStyle(\'gray\').setID("4").setLabel(\' \');\n Buttons[5] = new discordButton.MessageButton().setStyle(\'gray\').setID("5").setLabel(\' \');\n \n Buttons[6] = new discordButton.MessageButton().setStyle(\'gray\').setID("6").setLabel(\' \');\n Buttons[7] = new discordButton.MessageButton().setStyle(\'gray\').setID("7").setLabel(\' \');\n Buttons[8] = new discordButton.MessageButton().setStyle(\'gray\').setID("8").setLabel(\' \');\n\nmsg.channel.send(`\xe2\x81\xa3...`, { buttons:Buttons });\nRun Code Online (Sandbox Code Playgroud)\n它得到的错误:
\nDiscordAPIError: Invalid Form Body\ncomponents[0].components[5]: The specified component exceeds the maximum width\ncomponents[0].components[6]: The specified component exceeds …Run Code Online (Sandbox Code Playgroud) 因此,我有一个现有的乘客详细信息输入字段(姓名、地址、号码、电子邮件)。我想做的是使用添加按钮添加另一个乘客详细信息输入。到目前为止,这是我的按钮代码:
<div class="center">
<button
type="button"
class="next-button"
mat-flat-button
matTooltip="Add new passenger"
matTooltipClass="tooltipClass"
matTooltipPosition="below"
(click)=""
>
<mat-icon>add</mat-icon>
</button>
Run Code Online (Sandbox Code Playgroud)
我想以编程方式更改按钮图像和标题。当在故事板上设计按钮图像和标题(普通)时,它居中没有问题。但是当\xc4\xb1使用时;
\n startButton.setImage(UIImage(named: "StartButton"), for: .normal)\n startButton.setAttributedTitle(NSAttributedString(string: "START"), for: .normal)\nRun Code Online (Sandbox Code Playgroud)\n以编程方式更改按钮图像和标题。按钮标题未位于图像中心。看起来它位于图像的左侧。
\n我正在使用 PySimpleGui 制作一个 GUI,我希望我的一个按钮是一个圆圈,一个更大。有没有办法做到这一点?如果是这样,怎么办?我正在使用 TKinter 端口。
在 v5 中,尝试创建一个从深色模式切换到浅色模式的切换对我来说相当困难。
直接使用来自 MUI Sandbox MUI darkmode的代码,我尝试将代码分离以在 app.js 和我的 Navbarpractice.js 中工作。
应用程序.js
import React from "react";
import useMediaQuery from '@mui/material/useMediaQuery';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { Paper } from "@mui/material";
import BasicCard from "./components /Card.js";
import Navbarpractice from "./components /Navbar/Navbarpractice"
const ColorModeContext = React.createContext({ toggleColorMode: () => {} });
function App() {
const [mode, setMode] = React.useState('light');
const colorMode = React.useMemo(
() => ({
toggleColorMode: () => {
setMode((prevMode) => (prevMode …Run Code Online (Sandbox Code Playgroud) 在我的 Mac 应用程序中,我想在点击按钮时通过新视图显示本地 PDF 文件。StackOverflow 帖子(此处)展示了如何使用 UIViewRepresentable 对 iOS 应用程序执行此操作,但这不适用于 Mac 应用程序。
我有一个按钮,点击后会展开一张包含更多信息的卡片
我需要添加onKeyDown以button确保可访问性合规性吗?
或者这是多余的,因为该元素已经是 a button?
我还缺少其他需要遵守的内容WCAG 2.0吗?
这是我的可折叠按钮代码react
const ariaPressed = checked ? "true" : "false";
return (
<button
tabIndex={0}
role="button"
component="button"
aria-pressed={ariaPressed}
aria-expanded={ariaPressed}
onClick={toggleChecked}
>
{checked ? "Hide Versions" : "View Versions"}
</button>
);
Run Code Online (Sandbox Code Playgroud)
有一天,我在故事板中制作了带有标题标签、副标题标签和图像的按钮,并得到了这种效果
但现在当我尝试在代码中以编程方式执行此操作时,我遇到了问题,我看不到字幕..
private var firstPaidPack: UIButton = {
let button = UIButton(type: .custom)
let image = UIImage(systemName: "circle")
button.layer.cornerRadius = 15
button.backgroundColor = UIColor(white: 1, alpha: 0.3)
button.setImage(image, for: .normal)
button.setTitle("1.99$", for: .normal)
button.subtitleLabel?.textAlignment = .center
button.subtitleLabel?.text = "subtitle text to check how it..."
button.titleLabel?.font = UIFont(name: "Arial", size: screenWidth / 375 * 19)
return button
}()
Run Code Online (Sandbox Code Playgroud)