# 开发常用样式

## flex:水平方向-垂直居中

![flex垂直居中](https://github.com/ougege/blog/blob/master/Images/CSS/开发常用样式/demo_01.png)

::: code-group

```HTML
<div class="flex-ul row">
  <div class="flex-li">
    <div class="li-info">111</div>
  </div>
  <div class="flex-li">
    <div class="li-info">222</div>
  </div>
  <div class="flex-li">
    <div class="li-info">333</div>
  </div>
</div>

```

```CSS
.flex-ul{
  width:100%;
  display: flex;
}
.flex-ul.row{
  flex-direction: row;
}
.flex-ul.column{
  flex-direction: column;
}
.flex-ul > .flex-li{
  display: flex;
  flex-grow: 1;
  justify-content:center;
  align-items: center;
  height:auto;
}
.flex-ul .flex-li .li-info{
  flex-grow: 1;
  height:30px;
  line-height: 30px;
}
.flex-ul .flex-li .li-info {
  border:solid 1px #ddd;
}
.flex-label{
  flex-grow: 1;
}
.flex-content{
  flex-grow: 4;
}
```

:::

## flex:垂直方向-垂直居中

![flex垂直居中](https://github.com/ougege/blog/blob/master/Images/CSS/开发常用样式/demo_02.png)

::: code-group

```HTML
<div class="flex-ul column">
  <div class="flex-li">
    <div class="li-info">111</div>
  </div>
  <div class="flex-li">
    <div class="li-info">222</div>
  </div>
  <div class="flex-li">
    <div class="li-info">333</div>
  </div>
</div>
```

```CSS
.flex-ul{
  width:100%;
  display: flex;
}
.flex-ul.row{
  flex-direction: row;
}
.flex-ul.column{
  flex-direction: column;
}
.flex-ul > .flex-li{
  display: flex;
  flex-grow: 1;
  justify-content:center;
  align-items: center;
  height:auto;
}
.flex-ul .flex-li .li-info{
  flex-grow: 1;
  height:30px;
  line-height: 30px;
}
.flex-ul .flex-li .li-info {
  border:solid 1px #ddd;
}
.flex-label{
  flex-grow: 1;
}
.flex-content{
  flex-grow: 4;
}
```

:::

## flex:一端固定一端自适应

![flex-一端固定一端自适应](https://github.com/ougege/blog/blob/master/Images/CSS/开发常用样式/demo_04.png)

::: code-group

```HTML
<div class="flex">
  <div class="left">自适应</div>
  <div class="right">固定</div>
</div>
```

```CSS
.flex {
  display: flex;
}
.flex .left {
  flex: 1;
  background: #eee;
}
.flex .right {
  width: 40px;
  background: #999;
}
```

:::

## 文字两端且均分对齐

![文字两端且均分对齐](https://github.com/ougege/blog/blob/master/Images/CSS/开发常用样式/demo_03.png)

::: code-group

```HTML
<div class="space">O U G E G E</div>
```

```CSS
.space {
  display: block;
  text-align: justify;
}
.space::after {
  content: '';
  display: inline-block;
  width: 100%;
}
```

:::


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ougege.gitbook.io/blog/docs/articles/css/kai-fa-chang-yong-yang-shi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
