html5中怎么设置fieldset居中?

html5中怎么设置fieldset居中?,第1张

将fieldset的float:left去掉,不然会往左移的

设置左右magin为auto即可居中

fieldset {
    margin: 0 auto;
    float: none;
}

当然还有其他居中方法:用inline-block,position,还有flex都可以

样式中有个text-align,可以设置为center就可以居中了。

比如:<td style="text-align:center">要展示的文字</td>

另外,设置垂直方向的属性,可以使用:vertical-align,对应的值有top,middle,bottom等。

扩展资料:

text-align 属性

1、left把文本排列到左边

2、right把文本排列到右边

3、center把文本排列到中间

4、justify实现两端对齐文本效果

5、inherit规定应该从父元素继承 text-align 属性的值

注:水平对齐属性是 justify,它会带来自己的一些问题。

值 justify 可以使文本的两端都对齐。在两端对齐文本中,文本行的左右两端都放在父元素的内边界上。然后,调整单词和字母间的间隔,使各行的长度恰好相等,两端对齐文本在打印领域很常见。

<table style="margin:0 auto">
<tr><th>用户名称:</th>
<td>
<input type="text" name="username" placeholder="长度4-12,英文大小写字母">
</td><td><div></div></td></tr>
<tr><th>密 码:</th>
<td>
<input type="password" name="pwd" placeholder="长度6-20,大小写字母、数字或下划线">
</td><td><div></div></td></tr>
</table>

bool HelloWorld::init()
{
//////////////////////////////
// 1 super init first
if ( !CCLayer::init() )
{
return false;
}

this->m_size = CCDirector::sharedDirector()->getVisibleSize();

//第一个参数是文本框的大小,第二个是文本框在正常情况下的背景,第三个参数是按下时候的背景
//第四个参数是不可用的时候的背景,后三个参数可以省略
editBox = CCEditBox::create(CCSize(300,40),
CCScale9Sprite::create("99png"),
CCScale9Sprite::create("89png"));
editBox->setPosition(ccp(m_sizewidth/2,m_sizeheight/2));
this->addChild(editBox);
//设置预置文本
editBox->setPlaceHolder("please input:");

//设置文本字体的颜色

editBox->setFontColor(ccc3(255,0,0));

//设置最大长度 ,按说这个地方是输入框文字的长度,但是在win32上不管用,移植到android的时候是管用的

editBox->setMaxLength(1);

//setInputMode()设置输入类型,可以包括如下的几种
// kEditBoxInputModeAny: 开启任何文本的输入键盘,包括换行

// kEditBoxInputModeEmailAddr: 开启 邮件地址 输入类型键盘

// kEditBoxInputModeNumeric: 开启 数字符号 输入类型键盘

// kEditBoxInputModePhoneNumber: 开启 电话号码 输入类型键盘

// kEditBoxInputModeUrl: 开启 URL 输入类型键盘

// kEditBoxInputModeDecimal: 开启 数字 输入类型键盘,允许小数点

// kEditBoxInputModeSingleLine: 开启任何文本的输入键盘,不包括换行
editBox->setInputMode(kEditBoxInputModeAny);

//设置输入标志,可以有如下的几种
//kEditBoxInputFlagPassword: 密码形式输入

//kEditBoxInputFlagSensitive: 敏感数据输入、存储输入方案且预测自动完成

//kEditBoxInputFlagInitialCapsWord: 每个单词首字母大写,并且伴有提示

//kEditBoxInputFlagInitialCapsSentence: 第一句首字母大写,并且伴有提示

//kEditBoxInputFlagInitialCapsAllCharacters:所有字符自动大写
editBox->setInputFlag(kEditBoxInputFlagPassword);

//设置键盘中return键显示的字符,这个移植android的时候没有看出来

editBox->setReturnType(kKeyboardReturnTypeGo);

//包括这些选项

//kKeyboardReturnTypeDefault: 默认使用键盘return 类型

//kKeyboardReturnTypeDone: 默认使用键盘return类型为“Done”字样

//kKeyboardReturnTypeSend: 默认使用键盘return类型为“Send”字样

//kKeyboardReturnTypeSearch: 默认使用键盘return类型为“Search”字样

//kKeyboardReturnTypeGo: 默认使用键盘return类型为“Go”字样

//写上这句话的时候以下的四个函数才会被调用
editBox->setDelegate(this);
return true;
}

//实现以下的函数,观察他们是何时被调用的
void HelloWorld::editBoxEditingDidBegin(CCEditBox editBox)
{
CCLog("begin!");
CCLabelTTF ttf = CCLabelTTF::create("begin","",24);
ttf->setPosition(ccp(m_sizewidth/4,m_sizeheight1/5));
this->addChild(ttf);
}

void HelloWorld::editBoxEditingDidEnd(CCEditBox editBox)
{
CCLog("end!");
CCLabelTTF ttf = CCLabelTTF::create("end","",24);
ttf->setPosition(ccp(m_sizewidth/4,m_sizeheight4/5));
this->addChild(ttf);
}

void HelloWorld::editBoxTextChanged(CCEditBox editBox,const std::string & text)
{
CCLog("textChanged!");
CCLabelTTF ttf = CCLabelTTF::create("textChanged!","",24);
ttf->setPosition(ccp(m_sizewidth/4,m_sizeheight3/5));
this->addChild(ttf);
}

void HelloWorld::editBoxReturn(CCEditBox editBox)
{
CCLog("return");
CCLabelTTF ttf = CCLabelTTF::create("return","",24);
ttf->setPosition(ccp(m_sizewidth/4,m_sizeheight2/5));
this->addChild(ttf);

char str = (char )this->editBox->getText();
CCLabelTTF text = CCLabelTTF::create(str,"",24);
text->setPosition(ccp(m_sizewidth/2,m_sizeheight2/5));
this->addChild(text);
}

很多时候跟着书和不系统的视频学习,会发现没有方向,学了很多却不知道自己能够做出什么成绩。

学习要有一个清晰的职业学习规划,学习过程中会遇到很多问题,你可以到我们的web学习交流君 点击此处 ,

同时准备了基础,进阶学习资料。学友都会在里面交流,分享一些学习的方法和需要注意的小细节,每天也会准时讲一些项目实战案例。

在前端开发与探讨过程中熟悉并了解一些英语是非常关键的,下面整理了一些基础的前端英语单词,希望对给位有所帮助

首先、页面布局(layout)

header 头部/页眉;

index 首页/索引;

logo 标志;

nav/sub_nav 导航/子导航;

banner 横幅广告;

main/content 主体/内容;

container/con 容器;

wrapper/wrap 包裹(类似于container);

menu 菜单;

sub_menu/second_menu 子菜单/二级菜单;

list 列表;

section 分区/分块(类似于div);

article 文章;

aside 侧边栏/广告;

footer 页脚/底部;

title/sub_title 标题/副标题;

news 新闻;

hot 热点;

pro 产品(product);

company 公司;

msg/info 信息(message)/消息;

ads 广告(advertisements);

icon 小图标;

img (image);

copyright 版权;

contact_us 联系我们;

friend_link 友情链接;

tel 联系电话(telephone);

address 地址;

其次、CSS样式(style)

CSS 层叠样式表 (Cascading Style Sheets) ;

background 背景;

position 位置/定位;

relative/absolute/fixed 相对定位/绝对定位/固定定位;

float 浮动;

clear 清除;

vertical-align: middle/top/bottom; 垂直居中/上/下;

line-height 行高;

margin 外边距;

padding 内边距;

border 边框;

solid/dashed/dotted 实线/线虚线/点虚线;

border-radius 圆角;

shadow 阴影;

display 展示;

hidden 隐藏;

block/inline-block 块元素/行内块;

overflow 溢出;

cursor 光标;

animation 动画;

css sprites 雪碧图/精灵;

column 分列;

flex d性(布局);

然后、表单(form)与表格(table)

form 表单;

action 行为;

method 方式/方法;

input 输入框;

label 标签;

password 密码;

radio 单选框;

checkbox 复选框;

btn 按钮(button);

submit/reset 提交/重置;

textarea 文本域;

select/option 选择框/选择项;

placeholder 占位符(起提示作用);

search 搜索;

icon 小图标;

autofocus 自动聚焦;

disabled 禁用;

checked 选中(单选框/复选框);

selected 默认选择项(下拉选择框);

required 必填项;

readonly 只读;

table 表格;

thead/tbody/tfoot 表格标题/主体/底部;

colspan 跨列;

rowspan 跨行;

cellspacing 单元格间距(类似于margin);

cellpadding 单元格边距(类似于padding);

border-collapse: collapse; 边框

相关资料:

详解html中页面跳转传递参数的问题

html5关于标签的知识吧

相信很多人在刚接触前端或者中期时候总会遇到一些问题及瓶颈期,如学了一段时间没有方向感或者坚持不下去一个人学习枯燥乏味有问题也不知道怎么解决,对此我整理了一些资料 喜欢我的文章想与更多资深大牛一起讨论和学习的话 欢迎加入我的学习交流群

关于书籍:需要学习资料的小伙伴们可以加群, 点击此处

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML框架</title>
    <style type="text/css">
        bottomBtn{width: 960px;height: 500px;margin: 50px auto;padding: 20px;border: 1px solid #ddd;overflow: hidden;}
        bottomBtn ul{height: 150px;list-style: none;border: 1px solid #ddd;padding: 10px;}
        /重点在这里/
        bottomBtn ul li{width: 200px;height: 36%;vertical-align: middle;margin-bottom: 10px;border: 1px solid #333;text-align: center;}
        bottomBtn ul li imgWrap placeholder{height: 100%;display: inline-block;vertical-align: middle;}
        bottomBtn ul li imgWrap img{width:40px;height: auto;vertical-align:middle;}
    </style>
</head>
<body>
<div class="bottomBtn">
    <ul class="">
        <li id="btn1">
            <span class="footTitle">这是里显示的文本</span>
            <span class="imgWrap">
                <!--占位,用来撑满100%高度-->
                <span class="placeholder"></span>
                <!--替换成你本地的就可以了-->
                <img src="1png" alt="" />
            </span>
        </li>
        <li id="btn2">
            <span class="footTitle">这是里显示的文本</span>
            <span class="imgWrap">
                <span class="placeholder"></span>
                <img src="1png" alt="" />
            </span>
        </li>
    </ul>
</div>
</body>
</html>

在UITextField中自带placeholder属性,可以用于提示输入框信息。但是UITextView并不具备此功能
介绍两种方法来实现:
第一种:
初始化UITextView
//首先定义UITextView
UITextView textView = [[UITextView alloc] init];
textViewfont = [UIFont systemFontOfSize:14];
textViewframe =CGRectMake(10, 0, cellcontentViewboundssizewidth-20, side);
textViewautoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
textViewbackgroundColor = [UIColor whiteColor];
[cellcontentView addSubview:textView];
textViewhidden = NO;
textViewdelegate = self;
//其次在UITextView上面覆盖个UILable,UILable设置为全局变量。
uilabelframe =CGRectMake(17, 8, cellcontentViewboundssizewidth - side+10, 20);
uilabeltext = @"请填写审批意见";
uilabelenabled = NO;//lable必须设置为不可用
uilabelbackgroundColor = [UIColor clearColor];
[cellcontentView addSubview:uilabel];
实现UITextView的代理
-(void)textViewDidChange:(UITextView )textView
{
selfexamineText = textViewtext;
if (textViewtextlength == 0) {
uilabeltext = @"请填写审批意见";
}else{
uilabeltext = @"";
}
}
第二种:
UITextView 实现 placeholder 及隐藏键盘
#import <Foundation/Foundationh>
@interface UIPlaceHolderTextView : UITextView {
NSString placeholder;
UIColor placeholderColor;
@private
UILabel placeHolderLabel;
}
@property(nonatomic, retain) UILabel placeHolderLabel;
@property(nonatomic, retain) NSString placeholder;
@property(nonatomic, retain) UIColor placeholderColor;
-(void)textChanged:(NSNotification)notification;
@end
#import "UIPlaceHolderTextViewh"
@implementation UIPlaceHolderTextView
@synthesize placeHolderLabel;
@synthesize placeholder;
@synthesize placeholderColor;
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[placeHolderLabel release]; placeHolderLabel = nil;
[placeholderColor release]; placeholderColor = nil;
[placeholder release]; placeholder = nil;
[super dealloc];
}
- (void)awakeFromNib
{
[super awakeFromNib];
[self setPlaceholder:@""];
[self setPlaceholderColor:[UIColor lightGrayColor]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChanged:) name:UITextViewTextDidChangeNotification object:nil];
}
- (id)initWithFrame:(CGRect)frame
{
if( (self = [super initWithFrame:frame]) )
{
[self setPlaceholder:@""];
[self setPlaceholderColor:[UIColor lightGrayColor]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChanged:) name:UITextViewTextDidChangeNotification object:nil];
}
return self;
}
- (void)textChanged:(NSNotification )notification
{
if([[self placeholder] length] == 0)
{
return;
}
if([[self text] length] == 0)
{
[[self viewWithTag:999] setAlpha:1];
}
else
{
[[self viewWithTag:999] setAlpha:0];
}
}
- (void)setText:(NSString )text {
[super setText:text];
[self textChanged:nil];
}
- (void)drawRect:(CGRect)rect
{
if( [[self placeholder] length] > 0 )
{
if ( placeHolderLabel == nil )
{
placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectMake(8,8,selfboundssizewidth - 16,0)];
placeHolderLabellineBreakMode = UILineBreakModeWordWrap;
placeHolderLabelnumberOfLines = 0;
placeHolderLabelfont = selffont;
placeHolderLabelbackgroundColor = [UIColor clearColor];
placeHolderLabeltextColor = selfplaceholderColor;
placeHolderLabelalpha = 0;
placeHolderLabeltag = 999;
[self addSubview:placeHolderLabel];
}
placeHolderLabeltext = selfplaceholder;
[placeHolderLabel sizeToFit];
[self sendSubviewToBack:placeHolderLabel];
}
if( [[self text] length] == 0 && [[self placeholder] length] > 0 )
{
[[self viewWithTag:999] setAlpha:1];
}
[super drawRect:rect];
}
@end
//隐藏键盘,实现UITextViewDelegate
-(BOOL)textView:(UITextView )textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString)text
{
if ([text isEqualToString:@"\n"]) {
[m_textView resignFirstResponder];
return NO;
}
return YES;
}

一、页面布局(layout)
header 头部/页眉;
index 首页/索引;
logo 标志;
nav/sub_nav 导航/子导航;
banner 横幅广告;
main/content 主体/内容;
container/con 容器;
wrapper/wrap 包裹(类似于container);
menu 菜单;
sub_menu/second_menu 子菜单/二级菜单;
list 列表;
section 分区/分块(类似于div);
article 文章;
aside 侧边栏/广告;
footer 页脚/底部;
title/sub_title 标题/副标题;
news 新闻;
hot 热点;
pro 产品(product);
company 公司;
msg/info 信息(message)/消息;
ads 广告(advertisements);
icon 小图标;
img (image);
copyright 版权;
contact_us 联系我们;
friend_link 友情链接;
tel 联系电话(telephone);
address 地址;
二、CSS样式(style)
CSS 层叠样式表 (Cascading Style Sheets) ;
background 背景;
position 位置/定位;
relative/absolute/fixed 相对定位/绝对定位/固定定位;
float 浮动;
clear 清除;
vertical-align: middle/top/bottom; 垂直居中/上/下;
line-height 行高;
margin 外边距;
padding 内边距;
border 边框;
solid/dashed/dotted 实线/线虚线/点虚线;
border-radius 圆角;
shadow 阴影;
display 展示;
hidden 隐藏;
block/inline-block 块元素/行内块;
overflow 溢出;
cursor 光标;
animation 动画;
css sprites 雪碧图/精灵;
column 分列;
flex d性(布局);
三、表单(form)与表格(table)
form 表单;
action 行为;
method 方式/方法;
input 输入框;
label 标签;
password 密码;
radio 单选框;
checkbox 复选框;
btn 按钮(button);
submit/reset 提交/重置;
textarea 文本域;
select/option 选择框/选择项;
placeholder 占位符(起提示作用);
search 搜索;
icon 小图标;
autofocus 自动聚焦;
disabled 禁用;
checked 选中(单选框/复选框);
selected 默认选择项(下拉选择框);
required 必填项;
readonly 只读;
table 表格;
thead/tbody/tfoot 表格标题/主体/底部;
colspan 跨列;
rowspan 跨行;
cellspacing 单元格间距(类似于margin);
cellpadding 单元格边距(类似于padding);
border-collapse: collapse; 边框合并(用于table上);


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12969953.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2025-08-29
下一篇2025-08-29

发表评论

登录后才能评论

评论列表(0条)

    保存