问题描述
我似乎无法在这里找到我做错了什么。当元素悬停时,transform:translate 属性会导致不良影响。
请看这个代码笔。
https://codepen.io/kuromicho/pen/LYxrQPv
CSS
.row {
max-width: 600px;
margin: 0 auto;
border: 1px solid black;
}
.col {
display: block;
width:50%;
float: left;
border: 1px solid red;
}
.big-icon {
position: relative;
left: 50%;
transform: translateX(-50%);
transition: scale 0.2s;
}
.big-icon {
font-size: 300%;
color: #e67e22;
}
.big-icon:hover {
transform: scale(1.15);
}
HTML:
<head>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"
/>
</head>
<body>
<div class="row">
<div class="col">
<ion-icon name="infinite-sharp" class="big-icon"></ion-icon>
</div>
<div class="col">
<ion-icon name="cart-sharp" class="big-icon"></ion-icon>
</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://unpkg.com/ionicons@5.4.0/dist/ionicons.js"></script>
</html>
解决方法
我不知道您为什么在 CSS 中两次定义 Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName PresentationFramework
$myFont='Helvetica'
$mainForm=New-Object System.Windows.Forms.Form
$mainForm.StartPosition='CenterScreen'
$mainForm.Icon=[System.Drawing.Icon]::ExtractAssociatedIcon("$PSHOME\PowerShell.exe")
$mainForm.KeyPreview=$True
$mainForm.FormBorderStyle='Fixed3D'
$mainForm.Text='Test'
$mainForm.WindowState='Maximized'
$bounds=($mainForm.CreateGraphics()).VisibleClipBounds.Size
$dataGrid=New-Object System.Windows.Forms.DataGridView
$dataGrid.Size=New-Object System.Drawing.Size(($bounds.Width-20),$($bounds.Height-140))
$dataGrid.Location=New-Object System.Drawing.Size(10,60)
$dataGrid.Font=New-Object System.Drawing.Font($myFont,9,[System.Drawing.FontStyle]::Regular)
$dataGrid.DefaultCellStyle.WrapMode='True'
$dataGrid.AllowUserToAddRows=$false
$dataGrid.SelectionMode=0
$dataGrid.MultiSelect=$True
$dataGrid.ReadOnly=$false
$dataGrid.EnableHeadersVisualStyles=$True
$datagrid.Anchor='Top,Bottom,Left'
$mainForm.Controls.Add($dataGrid)
#Here goes your Data Source
$dataSource = Get-ChildItem "$HOME\Documents" -File|select Name,Length,LastWriteTime,CreationTime
$columns=$dataSource[0].PSobject.Properties.Name
$table = New-Object system.Data.DataTable
foreach($column in $columns)
{
$type=switch -Wildcard($column)
{
'Length'{[int]}
'*Time'{[datetime]}
Default{[string]}
}
$i = New-Object System.Data.DataColumn
$i.DataType = $type
$i.ColumnName = $column
$table.Columns.Add($i)
}
foreach($line in $dataSource)
{
$row = $table.NewRow()
foreach($column in $columns)
{
$row.$column = $line.$column
}
$table.Rows.Add($row)
}
# Here you bind your DataSource to your DataGridView
$dataGrid.DataSource=$table
$dataGrid.RowHeadersVisible=$false
$dataGrid.ColumnHeadersBorderStyle=2
$dataGrid.AutoSizeColumnsMode=[System.Windows.Forms.DataGridViewAutoSizeColumnMode]::AllCells
$dataGrid.ColumnHeadersHeight=25
$sum=0
$dataGrid.Columns.Width|%{$sum+=$_}
if($sum -lt $dataGrid.Width)
{
$dataGrid.Columns[-1].AutoSizeMode=[System.Windows.Forms.DataGridViewAutoSizeColumnMode]::Fill
}
$mainForm.ShowDialog()
类,但这是我在 CSS 文件底部的修复,请仔细查看我评论/删除的 CSS 行:>
big-icon