小编Liu*_* 刘研的帖子

保证金 - 顶部推动外部下调

我有一个标题div作为我的包装div中的第一个元素,但是当我在标题div中向h1添加一个上边距时,它会将整个标题div向下推.每当我将上边距应用于页面上的第一个可见元素时,我都会意识到这种情况.

这是一个示例代码段.谢谢!

div#header{
	width: 100%;
	background-color: #eee;
	position: relative;
}

div#header h1{
	text-align: center;
	width: 375px;
	height: 50px;
	margin: 50px auto;
	font-size: 220%;
	background: url('../../images/name_logo.png') no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
<div id="header">
	<h1>Title</h1>
	<ul id="navbar"></ul>
</div>
Run Code Online (Sandbox Code Playgroud)

html css xhtml

124
推荐指数
5
解决办法
7万
查看次数

CSS:父母没有边界的边缘

正如你在这张照片中看到的那样,我在div绿色内部有一个div没有顶部边框的橙色.橙色div有一个30px上边距,但它也推动了绿色div.当然,添加顶部边框将解决问题,但我需要绿色div顶部无边框.我能做什么?

.body {
	border: 1px solid black;
	border-top: none;
	border-bottom: none;
	width: 120px;
	height: 112px;
	background-color: lightgreen;
}

.body .container {
	background-color: orange;
	height: 50px;
	width: 50%;
	margin-top: 30px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="header">Top</div>
<div class="body">
	<div class="container">Box</div>
</div>
<div class="foot">Bottom</div>
Run Code Online (Sandbox Code Playgroud)

谢谢

css border margin collapse

52
推荐指数
2
解决办法
3万
查看次数

浮点长度值对像素单位有意义吗?

当我尝试为forums.asterisk.org网站编写时尚的CSS时,我看到它们在像素单元上使用浮点长度值,例如:font-size: 13.1px;.

据我所知,像素是屏幕中的最小单位,浮点长度值在像素单位上是否有意义?

截图

forums.asterisk.org站点使用像素单元上的浮点长度值

css pixel

12
推荐指数
1
解决办法
7469
查看次数

是否有正则表达式方法用另一组替换一组字符(如shell tr​​命令)?

shell tr命令支持用另一组替换一组字符.例如,echo hello | tr [a-z] [A-Z]将转换helloHELLO.

但是,在java中,我必须单独替换每个字符,如下所示

"10 Dogs Are Racing"
    .replaceAll ("0", "?")
    .replaceAll ("1", "?")
    .replaceAll ("2", "?")
    // ...
    .replaceAll ("9", "?")
    .replaceAll ("A", "?")
    // ...
;
Run Code Online (Sandbox Code Playgroud)

Apache的公地郎库提供了一个方便replaceChars的方法做这样的替换.

// half-width to full-width
System.out.println
(
    org.apache.commons.lang.StringUtils.replaceChars
    (
        "10 Dogs Are Racing",
        "0123456789ABCDEFEGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
        "???????????????????????????????????????????????????????????????"
    )
);
// Result:
// ?? ???? ??? ??????
Run Code Online (Sandbox Code Playgroud)

但正如你所看到的,在某个时候searchChars/replaceChars太长(也太无聊了,请,如果你想找到它复制的字符),并且可以通过一个简单的正则表达式来表示[0-9A-Za-z]/ [?-??-??-?].是否有正则表达方式来实现这一目标?

java regex replace

8
推荐指数
2
解决办法
1238
查看次数

如何覆盖现有的CSS让子<div> 1具有固定宽度,而子<div>具有父级的剩余宽度?

我正在尝试为StackExchange网站编写Firefox时尚css(全屏宽度样式).

在标记的问题列表页面(例如:https://stackoverflow.com/questions/tagged/java)中,HTML如下所示

<div class='question-summary'>
    <div class='statscontainer'>
        <div>n votes</div>
        <div>n answers</div>
        <div>n views</div>
    </div>
    <div class='summary'>
        <h3>Question title</h3>
        <div>question excerpt ...</div>
        <div>tag1 tag2 tagN </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

原始CSS在父/子1 /子2上使用固定宽度

<style>
    .question-summary
    {
        float: left;
        width: 730px;
        background-color: silver;
    }
    .statscontainer
    {
        float: left;
        width: 86px;
        margin-right: 8px;
        background-color: gray;
    }
    .summary
    {
        float: left;
        width: 635px;
        background-color: lightgray;
    }
</style>
Run Code Online (Sandbox Code Playgroud)

现在我尝试覆盖CSS以使其适合全屏宽度

    .question-summary
    {
        float: left;
        width: 100% !important;    /* parent: full screen width */ …
Run Code Online (Sandbox Code Playgroud)

css

6
推荐指数
1
解决办法
7049
查看次数

插入失败,但身份值增加,这会破坏原子性规则吗?

当我从大型Excel中将数据导入新表时,如果一个记录失败,则不会导入任何内容.我认为这是可以的,因为它符合原子性规则.但是,当我修复源数据错误并再次导入时,标识列不是从1开始,而是从一个大值开始.

例如

create table #test (id int identity(1,1), name varchar(4) default '')

insert into #test (name) values('1 insert will failed');
select ident_current('#test') as ident_current
insert into #test (name) values('2 insert will failed');
select ident_current('#test') as ident_current

insert into #test (name) values('3 OK');
select ident_current('#test') as ident_current

select * from #test

drop table #test
Run Code Online (Sandbox Code Playgroud)

结果

id          name 
----------- ---- 
3           3 OK
Run Code Online (Sandbox Code Playgroud)

维基百科描述了ACID如下

原子性

原子性要求每个事务都是"全有或全无":如果事务的一部分失败,则整个事务失败,数据库状态保持不变.原子系统必须保证每种情况下的原子性,包括电源故障,错误和崩溃.

因此,如果插入失败,SQL Server似乎不会让数据库状态(标识值)保持不变,那么,这会破坏ACID规则吗?

顺便说一下,当插入失败时,PostgreSQL不会让身份(串行)值增长.(更新:仅有时,请参阅评论.不要依赖于此.).

test=# create table AutoIncrementTest (id serial not …
Run Code Online (Sandbox Code Playgroud)

sql sql-server postgresql acid

3
推荐指数
1
解决办法
2290
查看次数

标签 统计

css ×4

acid ×1

border ×1

collapse ×1

html ×1

java ×1

margin ×1

pixel ×1

postgresql ×1

regex ×1

replace ×1

sql ×1

sql-server ×1

xhtml ×1