小编Dav*_*ekh的帖子

带有 RTL 元素的 CSS 边距

我有一个用style="direction:ltr " 声明的 DIV,以便从右到左显示项目。

我的问题是,如果我声明一个带有右边距 ( margin-right ) 的 div,当 div 为 RTL 时,该边距不会自动切换到左侧。

这迫使我用margin-left来设计每个我想要 RTL 的 div 。

我可以使用一些 CSS 参数来始终将边距放在 DIV 的末尾,并在使用 RTL 时自动切换吗?(水平)

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
.container{
    display:flex;
    flex-direction:row;
}

.text{
    margin-right:30px;
}

</style>

<div class="container">
    <div class="text">On this DIV the margin between the text and the icon is correct.</div>
    <div class="icon"><i class="fa fa-inbox" style="margin-right:3px; font-size:24px"></i><div>
</div>

<div class="container" style="direction:rtl">
    <div class="text">On this RTL DIV the margin between the …
Run Code Online (Sandbox Code Playgroud)

html css

5
推荐指数
2
解决办法
4689
查看次数

最小高度无法正常工作?

我正在尝试创建一个最小高度为 100% 的 DIV,这在 FireFox / IE 中不起作用。仅当使用“高度”属性时它才有效。

Chrome 运行正常。

<style>
    .page{
        min-height:100%;
        border:1px solid black;
    }
</style>
<html>
    <div class="page">
        With firefox / IE, this div is not stretching to take 100% of the total page height.
    </div>
</html>
Run Code Online (Sandbox Code Playgroud)

更新:

我知道我需要定义 body/html 的高度。这就说得通了。但即使使用这个解决方案,我仍然无法对子 div 使用 min-height 。请参阅下面的示例。子 div 没有占用父 div 的 33%。(在 Firefox 和 IE 中)

<style>
    .page{
        min-height:100%;
        border:1px solid black;
    }

    html,
    body {
        height: 100%;
    }

    .child{
        min-height:33%;
        border:1px solid black;
        display:flex;
    }

</style>
<html>
    <div …
Run Code Online (Sandbox Code Playgroud)

css firefox internet-explorer flexbox

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

在 PHP 会话中存储对象

在 PHP 中,将完整对象存储为会话变量是否被认为是最佳实践?

根据我的经验,有时有效,有时无效。有什么具体原因吗?

例子:

session_start();
$object = new sample_object();
$_SESSION['sample'] = $object;
Run Code Online (Sandbox Code Playgroud)

php oop serialization

2
推荐指数
1
解决办法
6160
查看次数

CSS FlexBox - 具有不同高度的子元素?

我正在尝试使用FlexBox设计子菜单.

FlexBox的默认行为是为所有子元素提供相同的大小.

这会在显示子菜单时导致所有项目展开.

使用Flexbox时有什么可以避免的吗?

Codepen:https://codepen.io/dsomekh/pen/oeogGq

<style>
.single_tag{
    display:flex;
    flex-direction:column;
    margin-right:6px;
    background-color:#ADD8E6;
    margin-bottom:6px;
    padding:2px;
    border-radius: 5px;
    border:2px solid red;

}

.container{
    display:flex;

    justify-content:center;
}

.dropdown-content {
    display: none;
    flex-direction:column;

}

.dropdown-content_second {
    display: none;
    flex-direction:column;

}

.dropdown-content a:hover {background-color: #f1f1f1}

.single_tag:hover .dropdown-content {
    display: flex;
}

</style>
<html>
<div class="container">
<div class="single_tag">First div
<div class="dropdown-content">
    <a href="#">Link 1</a>
    <a href="#">Link 2</a>
    <a href="#">Link 3</a>
  </div>
</div>
<div class="single_tag">Second div
<div class="dropdown-content">
    <a href="#">Link 1</a>
    <a href="#">Link 2</a>
    <a href="#">Link …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

2
推荐指数
1
解决办法
5824
查看次数

即使图标被隐藏,也保持相同的宽度

我有一个<div>,当它徘徊时,我正在显示一个<div>包含图标的孩子.

由于图标高于文本,因此新图标会更改父级<div>的高度.它也改变了<div>宽度,因为它插在最后.

我的问题:我希望<div>隐藏图标(带display:none)但仍然具有相同的大小,就像图标在那里(不使用静态宽度/高度).因此,当用户将鼠标悬停在<div>图标上时,将显示图标,但<div>尺寸将保持不变.

那可能吗?

.container {
  display: flex;
}

.row {
  border: 1px solid black;
  cursor: pointer;
  display: flex;
}

.row:hover .icon {
  display: flex;
}

.icon {
  display: none;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="row">
    <div class="text">This is my div. When it is hovered, I dont want it to change width and height because of the icon.</div>
    <div class="icon"><img src="http://i.imgur.com/NpIpU3F.png"></div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CodePen …

html css css3 flexbox

2
推荐指数
1
解决办法
53
查看次数

断字:断字在 Firefox 和 IE 中不起作用

我正在使用 flexbox 并尝试处理没有空格的长字符串。该变量word-break: break-word对我来说是理想的,因为它只中断长词,不像word-break: break-all刹车也会中断短词,而不是将它们放到下一行。

我的问题是它只适用于 Chrome。有没有办法在 IE / FIREFOX (使用 flexbox)中工作

代码笔:https ://codepen.io/anon/pen/wqLmoO

.page {
  display: flex;
  justify-content: center;
}

.content {
  display: flex;
  border: 2px solid blue;
  justify-content: center;
}

.item {
  display: flex;
  width: 33vw;
  word-break: break-word;
}

.item_brake_all {
  display: flex;
  width: 33vw;
  word-break: break-all;
}
Run Code Online (Sandbox Code Playgroud)
<p align=center><b><u>Can I get the two top DIVS to display correctly in IE / FIREFOX?</b></u>

  <p align=center>In this div the word should brake:
    <div …
Run Code Online (Sandbox Code Playgroud)

html css firefox internet-explorer flexbox

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

标签 统计

css ×5

flexbox ×4

html ×4

firefox ×2

internet-explorer ×2

css3 ×1

oop ×1

php ×1

serialization ×1