简体   繁体   English

PHP条件垂直对齐

[英]PHP conditional vertical alignment

I'm currently having a little trouble aligning some objects in a webpage I'm creating (with PHP/SQL/CSS). 我目前在对齐要创建的网页中的某些对象时遇到一些麻烦(使用PHP / SQL / CSS)。

So what I'm trying to achieve is a sort of timeline. 所以我想要实现的是一种时间表。 I've basically got three columns, the timeline so to speak in the center and events in two columns. 我基本上有三列,时间轴可以说在中心,事件可以分为两列。 I'd like each event have a corresponding <div> (containing a dot or the date, whatever) on the timeline. 我希望每个事件在时间轴上都有一个对应的<div> (包含点或日期,无论如何)。

My question is, how can I vertically align each group (event + dot) this way ? 我的问题是,如何以这种方式垂直对齐每个组(事件+点)?

sketch of the result i want to acheive 我要达到的结果草图

By that i mean, if the dot <div> in the center hits what's above first, stop. 我的意思是,如果中间的点<div>首先碰到上面的点,则停止。 Else wait for the event <div> to hit what's above. 否则,等待事件<div>击中上面的内容。

All those events are pulled out of an SQL database, that's why i'm lokking for a way to do this programmatically. 所有这些事件都从SQL数据库中提取出来,这就是为什么我偏向于以编程方式执行此操作的原因。

Hope my question is clear enough, i'm kind of new to developping if you didn't spot me already. 希望我的问题很清楚,如果您还没有发现我的话,我是一个新的开发人员。

Since you can have a box on the left and the right on the coloumb in the middle, you could add some boxed around these four elementes. 由于您可以在中间的co室的左侧和右侧有一个框,因此可以在这四个元素周围添加一些框。

I've made this example, based on your original drawing: http://puu.sh/95fyu/ab8e737fd5.jpg 我已经根据您的原始图形制作了这个示例: http : //puu.sh/95fyu/ab8e737fd5.jpg

This would ensure that the boxes in the middle will stay relatively close to the left and right boxes. 这将确保中间的框将保持相对靠近左侧框和右侧框。

To align the content of each box, you would have to split each into three sections: One for the left box, one for the middle one (containing two vertically stacked elements) and one for the right box. 要对齐每个框的内容,您必须将每个框分成三部分:一个用于左侧框,一个用于中间框(包含两个垂直堆叠的元素),另一个用于右侧框。 This can be seen on http://puu.sh/95fOQ/189e511405.jpg (marked with red). 可以在http://puu.sh/95fOQ/189e511405.jpg (带有红色标记)上看到。

However, the box on the right should be further down, compared to the surroding boxed, this can be solved by appling a margin to the top of the element equal to the height of the middle element. 但是,与装箱的替代框相比,右侧的框应位于更下方,这可以通过在元素的顶部施加等于中间元素高度的边距来解决。

The arrows will have to be drawn, using the relative placement of the different boxes. 必须使用不同框的相对位置绘制箭头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM