- border-style
- Краткая информация
- Версии CSS
- Описание
- Синтаксис
- Значения
- Объектная модель
- Браузеры
- CSS border-style Property
- Example
- Definition and Usage
- Browser Support
- Form Border Style Перечисление
- Определение
- Примеры
- Комментарии
- How to create a WPF Window without a border that can be resized via a grip only?
- 5 Answers 5
- Removing window border?
- 4 Answers 4
border-style
Internet Explorer | Chrome | Opera | Safari | Firefox | Android | iOS | |
6.0+ | 8.0+ | 1.0+ | 3.5+ | 1.0+ | 1.0+ | 1.0+ | 1.0+ |
Краткая информация
Значение по умолчанию | none |
---|---|
Наследуется | Нет |
Применяется | Ко всем элементам |
Ссылка на спецификацию | http://www.w3.org/TR/CSS21/box.html#propdef-border-style |
Версии CSS
Описание
Устанавливает стиль границы вокруг элемента. Допустимо задавать индивидуальные стили для разных сторон элемента.
Синтаксис
border-style: [none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset] <1,4>| inherit
Значения
Для управления видом границы предоставляется несколько значений свойства border-style . Вид зависит от используемого браузера и заданной толщины границы. В табл. 1 приведены названия стилей и получаемая рамка при разных значениях толщины — 1, 3, 5 и 7 пикселов.
1 пиксел | 3 пиксела | 5 пикселов | 7 пикселов | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Число значений | Результат |
---|---|
1 | Стиль границы будет задан для всех сторон элемента. |
2 | Первое значение устанавливает стиль верхней и нижней границы, второе — левой и правой. |
3 | Первое значение задает стиль верхней границы, второе — одновременно левой и правой границы, а третье — нижней границы. |
4 | Поочередно устанавливается стиль верхней, правой, нижней и левой границы. |
HTML5 CSS2.1 IE Cr Op Sa Fx
Результат данного примера показан на рис. 1.
Рис. 1. Применение свойства border-style
Объектная модель
[window.]document.getElementById(» elementID «).style.borderStyle
Браузеры
Браузер Internet Explorer до шестой версии включительно при толщине границы 1px отображает dotted как dashed . При толщине 2px и выше значение dotted работает корректно. Эта ошибка исправлена в IE7, но только для всех границ толщиной 1px. Если одна из границ блока имеет толщину 2px и выше, то в IE7 значение dotted превращается в dashed .
Internet Explorer до версии 7.0 включительно не поддерживает значения hidden и inherit .
Стиль границы в разных браузерах может несколько различаться при использовании значений groove , ridge , inset или outset .
CSS border-style Property
Example
Set a style for the border:
More «Try it Yourself» examples below.
Definition and Usage
The border-style property sets the style of an element’s four borders. This property can have from one to four values.
- border-style: dotted solid double dashed;
- top border is dotted
- right border is solid
- bottom border is double
- left border is dashed
- border-style: dotted solid double;
- top border is dotted
- right and left borders are solid
- bottom border is double
- border-style: dotted solid;
- top and bottom borders are dotted
- right and left borders are solid
- border-style: dotted;
- all four borders are dotted
Default value: | none |
---|---|
Inherited: | no |
Animatable: | no. Read about animatable |
Version: | CSS1 |
JavaScript syntax: | object.style.borderStyle=»dotted double» Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
border-style | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Note: The value «hidden» is not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 and later support «hidden».
Form Border Style Перечисление
Определение
Задает стили границ формы. Specifies the border styles for a form.
Фиксированная трехмерная граница. A fixed, three-dimensional border.
Толстая фиксированная граница стиля диалогового окна. A thick, fixed dialog-style border.
Фиксированная граница из одной линии. A fixed, single-line border.
Неизменяемая граница окна инструментов. A tool window border that is not resizable. Окно инструментов не отображается ни на панели задач, ни в окне, появляющемся при нажатии пользователем сочетания клавиш ALT+TAB. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB. Хотя формы, которые задают FixedToolWindow, обычно не отображаются в панели задач, необходимо также гарантировать, что для свойства ShowInTaskbar устанавливается значение false , так как его значение по умолчанию равно true . Although forms that specify FixedToolWindow typically are not shown in the taskbar, you must also ensure that the ShowInTaskbar property is set to false , since its default value is true .
Нет границы. No border.
Граница с изменяемыми размерами. A resizable border.
Изменяемая граница окна инструментов. A resizable tool window border. Окно инструментов не отображается ни на панели задач, ни в окне, появляющемся при нажатии пользователем сочетания клавиш ALT+TAB. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB.
Примеры
В этом примере стиль границы формы изменяется на Fixed3d и отображает сведения о границе с помощью метки. In this example, you change the form border style to Fixed3d and display the border’s information using a label. В этом примере предполагается, что вы уже создали Form именованный объект Form1 . This example assumes that you have already created a Form named Form1 .
Комментарии
Это перечисление используется классом Form. This enumeration is used by the Form class. Он представляет различные стили формы. It represents the different styles of the form. По умолчанию используется стиль Sizable . The default style is Sizable .
How to create a WPF Window without a border that can be resized via a grip only?
If you set ResizeMode=»CanResizeWithGrip» on a WPF Window then a resize grip is shown in the lower right corner, as below:
If you set WindowStyle=»None» as well the title bar disappears but the grey bevelled edge remains until you set ResizeMode=»NoResize» . Unfortunately, with this combination of properties set, the resize grip also disappears.
I have overridden the Window ‘s ControlTemplate via a custom Style . I want to specify the border of the window myself, and I don’t need users to be able to resize the window from all four sides, but I do need a resize grip.
Can someone detail a simple way to meet all of these criteria?
- Do not have a border on the Window apart from the one I specify myself in a ControlTemplate .
- Do have a working resize grip in the lower right corner.
- Do not have a title bar.
5 Answers 5
If you set the AllowsTransparency property on the Window (even without setting any transparency values) the border disappears and you can only resize via the grip.
Result looks like:
I was trying to create a borderless window with WindowStyle=»None» but when I tested it, seems that appears a white bar in the top, after some research it appears to be a «Resize border», here is an image (I remarked in yellow):
After some research over the internet, and lots of difficult non xaml solutions, all the solutions that I found were code behind in C# and lots of code lines, I found indirectly the solution here: Maximum custom window loses drop shadow effect
Note : You need to use .NET 4.5 framework, or if you are using an older version use WPFShell, just reference the shell and use Shell:WindowChrome.WindowChrome instead.
I used the WindowChrome property of Window, if you use this that white «resize border» disappears, but you need to define some properties to work correctly.
CaptionHeight: This is the height of the caption area (headerbar) that allows for the Aero snap, double clicking behaviour as a normal title bar does. Set this to 0 (zero) to make the buttons work.
ResizeBorderThickness: This is thickness at the edge of the window which is where you can resize the window. I put to 5 because i like that number, and because if you put zero its difficult to resize the window.
After using this short code the result is this:
And now, the white border disappeared without using ResizeMode=»NoResize» and AllowsTransparency=»True» , also it shows a shadow in the window.
Later I will explain how to make to work the buttons (I didn’t used images for the buttons) easily with simple and short code, Im new and i think that I can post to codeproject, because here I didn’t find the place to post the tutorial.
Maybe there is another solution (I know that there are hard and difficult solutions for noobs like me) but this works for my personal projects.
Removing window border?
I have a window with a solid border around it. How can I remove the border (all of the non-client area) by using SetWindowLong and GetWindowLong?
4 Answers 4
WS_CAPTION is defined as (WS_BORDER | WS_DLGFRAME). You can get away with removing just these two styles, since the minimize maximize and sytem menu will disappear when the caption disappears, but it’s best to remove them as well.
It’s also best to remove the extended border styles.
And finally, to get your window to redraw with the changed styles, you can use SetWindowPos.
The following Delphi codes does it:
Of course, these API calls look the same in all languages.
This line of code below removes the border of any given window, and remains only its client:
You can use WS_POPUPWINDOW instead in the third parameter of SetWindowLong function. It also removes the borders of the given window and works too, but the difference is that it also draws outlined black rectangle all over the remaining client of the window. The thickness of that outlined rectangle is 1 pixel. WS_POPUP doesn’t draw that rectangle, actually it doesn’t draw anything, just only remove window’s borders.
If you are about to return back the borders of the window, before you use that line of code I posted above, call first that line of code below:
but of course that this function retuns the styles of the window, so create new variable that will keep these styles, i.e. set this variable to the return value of that function.
Then you use SetWindowLong as I showen above to remove its borders, and when you want later to restore its borders back, just recall again SetWindowLong , the first two parameters are same (hWnd and GWL_STYLE), but the third parameter is the styles of the window that returned from GetWindowLong . If you don’t want to call GetWindowLong , but still return the borders of the window, then you can use SetWindowLong with the same first two parameters, and in the third parameter, you can use one of the following: WS_OVERLAPPED or/and WS_OVERLAPPEDWINDOW or/and WS_SIZEFRAME .
NOTE: If you try my answer, but it doesn’t work for you, this can be, because that the both functions SetWindowLong and GetWindowLong have been superseded and doesn’t work for you, and that because they are compatible with only 32-bit version of Windows. Probably you are using 64-bit version of Windows, then use SetWindowLongPtr and GetWindowLongPtr instead, which are compatible with both 32-bit and 64-bit versions of Windows. MSDN informs that about these functions in the Note section. Just search for them in that site. Here are the links to them: