javascript - Sticky button stickied left taking up whole width? - Stack Overflow

Hello I have a button that is stickied to the bottom left but taking up whole space for some reason. Co

Hello I have a button that is stickied to the bottom left but taking up whole space for some reason. Commenting display: flex and flex-direction: column in .todo-list does not allow the plus button to stay stickied to the bottom of the container on the container resize

Button:

<div className="todo-list">            
    <button className="add-task-button" onClick={handleShowInput}>
        <img src={addIcon} alt="Add Task" className="add-icon" />
    </button>
</div>

Style:

.todo-list {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    display: flex;
    flex-direction: column;


    p {
        margin: 0 0 0 2.4em;
    }

    ul {
        flex-grow: 1;
    }

    .add-task-button {
        position: sticky;
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        height: auto;
        bottom: 1em;
        left: 1em;
        width: auto;

        .add-icon {
            width: 2.2em;
            
        }

        &:hover {
            transform: scale(1.1);
        }
    }
}

Please help as you are my only hope anymore

Hello I have a button that is stickied to the bottom left but taking up whole space for some reason. Commenting display: flex and flex-direction: column in .todo-list does not allow the plus button to stay stickied to the bottom of the container on the container resize

Button:

<div className="todo-list">            
    <button className="add-task-button" onClick={handleShowInput}>
        <img src={addIcon} alt="Add Task" className="add-icon" />
    </button>
</div>

Style:

.todo-list {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    display: flex;
    flex-direction: column;


    p {
        margin: 0 0 0 2.4em;
    }

    ul {
        flex-grow: 1;
    }

    .add-task-button {
        position: sticky;
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        height: auto;
        bottom: 1em;
        left: 1em;
        width: auto;

        .add-icon {
            width: 2.2em;
            
        }

        &:hover {
            transform: scale(1.1);
        }
    }
}

Please help as you are my only hope anymore

Share Improve this question edited Nov 20, 2024 at 6:33 Amadeus asked Nov 20, 2024 at 6:22 AmadeusAmadeus 4425 silver badges18 bronze badges 1
  • 1 you didn't show the css for the container. But I am guessing it has flex display with flex-direction as column. So every child item will have entire width. If you want to show something else beside the button just add it in same div. – Anubhav Sharma Commented Nov 20, 2024 at 6:26
Add a comment  | 

1 Answer 1

Reset to default 1

The width in your style can be given a fixed width

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742377318a4432448.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信