定位元素到左下角没有覆盖任何东西

时间:2017-03-01 12:48:05

标签: html css css-position

我在父块中有两个元素,我想要一个在左上角,第二个在右下角,我也需要它们不要相互叠加。

我试过了:

  • absolute定位:它们叠加

  • flexbox:当空间太小而第二个元素被创建一个新行时,它会浮动到左边

有办法吗?

1 个答案:

答案 0 :(得分:1)

当重叠即将发生时,您将不得不添加条件样式并将正确的绝对元素的位置更改为相对

CREATE PROCEDURE [CallSpecificStoredProcedure]

 @Name VARCHAR(50)
,@StartDate DATETIME
,@EndDate DATETIME

AS
BEGIN
CREATE TABLE #IdNumbers
(   
    Id UNIQUEIDENTIFIER, 
    Number INT
)

INSERT INTO #IdNumbers EXEC GetIdNumbers @StartDate, @EndDate  --Hope here you insert your numbers

DECLARE @Id UNIQUEIDENTIFIER
DECLARE @Number INT

DECLARE NUMBERS_CURSOR CURSOR 
  LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR 
SELECT Id, Number
FROM #IdNumbers

OPEN NUMBERS_CURSOR 
FETCH NEXT FROM NUMBERS_CURSOR INTO @Id, @Number 
WHILE @@FETCH_STATUS = 0 --If there is still rows
BEGIN 
    --here your logic
    IF @Number = 1
    BEGIN
     EXEC StoredProcedure1 @Id, @Number, @Name, @StartDate, @EndDate
    END
    IF @Number = 2
    BEGIN
     EXEC StoredProcedure2 @Id, @Number, @Name, @StartDate, @EndDate
    END

    FETCH NEXT FROM NUMBERS_CURSOR INTO @Id, @Number 
END
CLOSE NUMBERS_CURSOR 
DEALLOCATE NUMBERS_CURSOR 

当视口宽度低于1000px时(元素将彼此重叠) - 只需将定位更改为相对,以避免这种情况。

https://jsfiddle.net/f3t2rgc8/