border

* { box-sizing: border-box; } 的作用

时光怂恿深爱的人放手 提交于 2020-01-13 00:14:41
box-sizing:border-box; 是CSS3新增属性,了解这个属性,我们先从块级元素的盒子大小说起。 通常一个块级元素实际所占宽高度=外边距(margin)+ 边界宽度(border-width) + 内边距(padding)+ 高度(height) / 宽度(width) 如果设置了border-box,实际所占宽高度 = 设置的高度(height)/ 设置的宽度(width)+ 外边距(margin) 你运行下面的代码就很好理解了 <style> #div1 {box-sizing:border-box; height:200px; width:200px; background:red; margin:10px; border:1px solid #000; padding:20px;} #div2 {box-sizing:content-box; height:200px; width:200px; background:red; margin:10px; border:1px solid #000; padding:20px;} </style> <div id="div1">border-box</div> <div id="div2">content-box</div> 对于设置这个属性的好处,更多是居于排版问题,很多情况下很实用,简化了计算位置的问题

CSS3 拯救我的布局吧box-sizing

ぃ、小莉子 提交于 2020-01-13 00:11:14
一、CSS常见的两栏布局 如上图,是一个很简单的两栏布局,就是一个宽度为960px;并且页面居中显示,侧边栏栏宽度为220px;主内容宽度720px;两者有一个20px的间距,并且有页眉和页脚。 代码也很简单: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head lang="en-US"> <title> 两栏布局</title> </head> <style type="text/css"> *{ margin:0; padding:0; } .wrapper{ width:960px; margin-left:auto; margin-right: auto; color:#fff; font-size:30px; text-align:center; background: blanchedalmond; } #header{ height:100px; background:#38382e; margin-bottom:10px; } .side{ float:left; width:220px; margin-right: 20px; margin-bottom:10px; height

css3整理--box-sizing

徘徊边缘 提交于 2020-01-13 00:10:32
box-sizing语法:   box-sizing : content-box || border-box || inherit   参数取值:   content-box:此值为其默认值,其让元素维持W3C的标准Box Model,也就是说元素的宽度/高度(width/height)等于元素边框宽度(border)加上元素内边距(padding)加上元素内容宽度 /高度(content width/height)即:Element Width/Height = border+padding+content width/height。   border-box:此值让元素维持IE传统的Box Model(IE6以下版本),也就是说元素的宽度/高度等于元素内容的宽度/高度。这里的content width/height包含了元素的border,padding,内容的width/height。即此处的内容宽度/高度=width /height-border-padding。    在实际应用中,该属性有个非常有用的地方,即根据百分比为元素设置宽度时。此时,如果元素有padding或者border,将box-sizing设置为border-box会非常有用。 例如: <ul> <li style="box-sizing:border-box; padding:0 10px; width

将这段美化的css代码

怎甘沉沦 提交于 2020-01-12 15:55:04
很多时候如果不是用了很多样式,很难把边框修饰得好看,看了一篇博文,觉得真的挺漂亮,也挺好看。 转载的博文地址 将这段美化的css代码 border:1px solid #96c2f1;background:#eff7ff 应用到div中, <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> border:1px solid #96c2f1;background:#eff7ff</div> 效果如下。 border:1px solid #96c2f1;background:#eff7ff 以下还有十个示例。 border:1px solid #9bdf70;background:#f0fbeb border:1px solid #bbe1f1;background:#eefaff border:1px solid #cceff5;background:#fafcfd border:1px solid #ffcc00;background:#fffff7 border:1px solid #cee3e9;background:#f1f7f9 border:1px solid #a9c9e2;background:#e8f5fe border:1px solid #e3e197;background:

盒模型与布局

血红的双手。 提交于 2020-01-12 09:16:11
1.盒模型 一个元素在页面中相当于一个盒子,包括margin、border、padding、content,如下图所示: 图1 css盒子 盒子模型包括IE盒模型与标准盒模型。 div{ width: 100px; height: 50px; border: 2px; padding: 10px; margin: 20px; } 标准盒子模型: 元素所占宽度: width = margin+ border + padding + width(内容宽度), 元素所占高度height同理。 css中指定的宽度是content宽度,高度是content高度。 div实际所占的宽度width = width(content宽度) + padding-left + padding-right + border-left + border-right + margin-left + margin-right= 100px + 10px +10px + 2px + 2px +20px +20px = 164px; div实际所占的高度height = height(content高度) + padding-top + padding-bottom + border-top + border-bottom + margin-top +margin-bottom= 50px + 10px +

How to set border color of certain Tkinter widgets?

◇◆丶佛笑我妖孽 提交于 2020-01-12 03:06:30
问题 I'm trying to change the background color of my Tkinter app, but for certain widgets it leaves a white border around the edges. For example, this: from tkinter import * COLOR = "black" root = Tk() root.config(bg=COLOR) button = Button(text="button", bg=COLOR) button.pack(padx=5, pady=5) entry = Entry(bg=COLOR, fg='white') entry.pack(padx=5, pady=5) text = Text(bg=COLOR, fg='white') text.pack(padx=5, pady=5) root.mainloop() How can I set border colour of certain Tkinter widgets? 回答1: Just use

C# WPF聊天界面(3/3)

匆匆过客 提交于 2020-01-11 18:54:00
微信公众号: Dotnet9 ,网站: Dotnet9 ,问题或建议: 请网站留言 , 如果对您有所帮助: 欢迎赞赏 。 C# WPF聊天界面(3/3) 阅读导航 本文背景 代码实现 本文参考 1.本文背景 系列文章最后一篇,一个完整的聊天界面。当然只看效果,具体的项目需要将左侧好友列表、中间会话列表、右侧联系人简况做成MVVM绑定的形式,做成模板才是一个完整的项目,本系列只是对界面的一个设计参考。 前面两篇文章: C# WPF联系人列表(1/3) C# WPF简况(2/3) 三篇文章最终效果如下: 2.代码实现 使用 .Net CORE 3.1 创建名为 “Chat” 的WPF项目,添加 MaterialDesignThemes(3.0.1)、MaterialDesignColors(1.2.2)两个Nuget库,文中图片已全部替换为站长网站logo图片外链,直接Copy文中代码即可运行,大家亦可下载原作者源码研究学习,文末会给出源码下载链接。 2.1 引入MD控件样式文件 使用MD控件的常规操作,需要在App.xaml中引入4个样式文件: <Application x:Class="Chat.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas

C# WPF简况(2/3)

会有一股神秘感。 提交于 2020-01-11 17:40:09
微信公众号: Dotnet9 ,网站: Dotnet9 ,问题或建议: 请网站留言 , 如果对您有所帮助: 欢迎赞赏 。 C# WPF简况(2/3) 阅读导航 本文背景 代码实现 本文参考 1.本文背景 承接上文( C# WPF联系人列表(1/3) ),添加好友简况。 本文效果如下: 2.代码实现 使用 .Net CORE 3.1 创建名为 “Chat” 的WPF项目,添加 MaterialDesignThemes(3.0.1)、MaterialDesignColors(1.2.2)两个Nuget库,文中部分图片可在文末视频配套源码中下载。 2.1 引入MD控件样式文件 使用MD控件的常规操作,需要在App.xaml中引入4个样式文件 <Application x:Class="Chat.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries>

CSS盒模型详解(图文教程)

空扰寡人 提交于 2020-01-11 09:14:02
本文最初发表于 博客园 ,并在 GitHub 上持续更新。以下是正文。 盒子模型 前言 盒子模型,英文即box model。无论是div、span、还是a都是盒子。 但是,图片、表单元素一律看作是文本,它们并不是盒子。这个很好理解,比如说,一张图片里并不能放东西,它自己就是自己的内容。 盒子中的区域 一个盒子中主要的属性就5个:width、height、padding、border、margin。如下: width和height: 内容 的宽度、高度(不是盒子的宽度、高度)。 padding:内边距。 border:边框。 margin:外边距。 盒子模型的示意图: 代码演示: 上面这个盒子,width:200px; height:200px; 但是真实占有的宽高是302*302。 这是因为还要加上padding、border。 注意: 宽度和真实占有宽度,不是一个概念! 来看下面这例子。 标准盒模型和IE盒模型 我们目前所学习的知识中,以标准盒子模型为准。 标准盒子模型: IE盒子模型: 上图显示: 在 CSS 盒子模型 (Box Model) 规定了元素处理元素的几种方式: width和height: 内容 的宽度、高度(不是盒子的宽度、高度)。 padding:内边距。 border:边框。 margin:外边距。 CSS盒模型和IE盒模型的区别: 在 标准盒子模型 中,

make part of div border transparent html

断了今生、忘了曾经 提交于 2020-01-11 08:31:12
问题 Can I make part (from x1 to x2) of div border transparent? If not what approach can you advice? My idea [very bad] is to draw border in canvas element and place it (canvas body is trasparent) over div element. 回答1: Since DIVs have only 4 elements (top, bottom, left, right) you can't make part of a border transparent AFAIK. However, you could create elements that would overlay your div and use relative positioning to build a border to your taste. For example: <style> .multiborder{ border:1px