HTML5中 基本用法及属性 韩俊强的博客

从今天开始更新H5相关学习:希望大家能一起学习,多学习一门语言,多一门乐趣!

了解Html5:




Html5基本属性:



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>html的属性</title>
</head>
<body bgcolor="#ffe4c4">
<!--<body background=".idea/images/1.jpg">-->

     <a href="hrefs.html" target="_blank">打开本地(target是否覆盖上一页)</a>
     <h1 align="center">标题1</h1>
     <h2 class="h2ID">标题2-class属性</h2>
     <h2 id="hID">标题3-id属性</h2>
</body>
</html>

(1)h1-h6 分别代表标题的不同字号:如图效果

<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>H5基础</title>
</head>
<body>
 <h1>标题1</h1>
 <h2>标题2</h2>
 <h3>标题3</h3>
 <h4>标题4</h4>
 <h5>标题5</h5>
 <h6>标题6</h6></p>
 <p>段落</p>
 <a href="http://blog.csdn.net/qq_31810357">小韩哥的博客</a>
 <img src=".idea/images/1.jpg">
  HaRi
</body>
</html>



(2)header头部和body主题

(3)a标签下属性herf关联链接如下图:

其中a标签下target属性有四个:_black._top._self_parent  //black是不被覆盖的,而默认是被覆盖的!


每日更新关注:http://weibo.com/hanjunqiang  新浪微博!

iOS开发者交流QQ群: 446310206 



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) cell?.imageView?.image = UIImage(named: "highlightedImage") } ### 回答2: 在 Swift ,可以使用 `UITableViewDelegate` 协议的 `didSelectRowAt` 方法来实现点击 UITableViewCell 进行高亮图片的效果。以下是一个示例代码: 首先,在你的视图控制器设置 `UITableViewDelegate`: ```swift class ViewController: UIViewController, UITableViewDelegate { // ... } ``` 在 `viewDidLoad` 方法,将 `UITableViewDelegate` 设置为你的 `UITableView` 的代理: ```swift override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self } ``` 然后,实现 `didSelectRowAt` 方法来处理选 cell 的操作,可以在这个方法获取 cell 的索引并更改其状态: ```swift func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let cell = tableView.cellForRow(at: indexPath) else { return } // 选时的高亮效果,可以自行修改 cell.contentView.backgroundColor = .yellow } ``` 最后,为了取消高亮效果,还需要实现 `didDeselectRowAt` 方法: ```swift func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { guard let cell = tableView.cellForRow(at: indexPath) else { return } // 取消高亮效果 cell.contentView.backgroundColor = .white } ``` 以上是一个点击 UITableViewCell 高亮图片的 Swift 代码示例,你可以根据自己的需求修改高亮效果的样式和图片。 ### 回答3: 下面是一个 Swift 的代码示例,用于在点击表格单元格时高亮显示图片。 ```swift import UIKit class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { let cellID = "cellIdentifier" let colors = [UIColor.red, UIColor.green, UIColor.blue] var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView = UITableView(frame: self.view.frame) tableView.delegate = self tableView.dataSource = self tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellID) self.view.addSubview(tableView) } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return colors.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath) cell.selectionStyle = .none cell.textLabel?.text = "Row \(indexPath.row)" cell.textLabel?.textColor = UIColor.white cell.backgroundColor = colors[indexPath.row] return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) cell?.imageView?.highlightedImage = UIImage(named: "highlighted_image") cell?.setHighlighted(true, animated: true) } func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) cell?.imageView?.highlightedImage = nil cell?.setHighlighted(false, animated: true) } } ``` 上述代码,我们创建了一个包含了不同颜色单元格的表格视图。当点击单元格时,我们设置`imageView`的`highlightedImage`为一个高亮图片,并将单元格的高亮状态设置为`true`。当取消选单元格时,我们将`highlightedImage`设置为`nil`,并将单元格的高亮状态设置为`false`。请确保你有一个名为`highlighted_image`的图片文件,且存在于项目

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

韩俊强

奖励一杯咖啡☕️

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值