I've tried several variations based on search results and StackOverflow results and referenced existing code.
With this code
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<div class="table-row row d-flex flex-column align-items-center">
<div class="col">
<span class="align-middle">
<button type="submit" class="searchbtn emailRemoveBtn float-start align-self-center" name="command" value="Delete email #i">
<i class="fa-solid fa-xmark sm"></i>
<span aria-hidden="true"></span>
</button>
<input readonly class="align-self-center" style="border-style: hidden;" />
</span>
</div>
</div>
The emails don't vertically center as shown here:
I'm new to this and it's probably something small. Do you see what I'm missing to center the emails vertically?
Don't use flexbox and floats together.
Don't use floats at all, except to wrap text around images. They're not for structural layout, just for content layout.
Don't introduce table row layout here (unless you actually have tabular data).
Don't use rows and explicit flex layout. Bootstrap 5 rows already have flexbox applied, but they require containers and columns, which you apparently don't need here, having only one column per row. You could apply the same principles to grid rows, though.
justify-content aligns content along the primary flex axis, not align-items.
Bootstrap provides border classes which you can use to remove border. Custom styles should be put on custom classes anyway, not in the markup.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<div class="d-flex flex-column justify-content-center mt-1 py-2 bg-secondary">
<div class="text-center">
<button type="submit" class="btn btn-primary searchbtn emailRemoveBtn" name="command" value="Delete email #i">
<i class="fa-solid fa-xmark sm"></i>
<span aria-hidden="true"></span>
</button>
<input readonly class="align-self-center border-0" />
</div>
</div>
<div class="d-flex flex-column justify-content-center mt-1 py-2 bg-secondary">
<div class="text-center">
<button type="submit" class="btn btn-primary searchbtn emailRemoveBtn" name="command" value="Delete email #i">
<i class="fa-solid fa-xmark sm"></i>
<span aria-hidden="true"></span>
</button>
<input readonly class="align-self-center border-0" />
</div>
</div>
Related
This question already has answers here:
Multiple lines of input in <input type="text" />
(10 answers)
Closed last year.
Currently my code looks like this:
I want the text to be aligned to the top of the input text field.
I have tried using align-text-top, align-top & adding a custom class with vertical-align: top; and vertical-align: text-top;
Can't figure it out. Any help will be greatly appreciated.
<body>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<div class="main-wrapper" style="object-fit: contain;">
<!-- navbar -->
<div class="navbarDesktop d-none d-sm-flex">
<img class="p-3" style="width: auto; height: auto; max-width: 40%; object-fit: contain;" src="../../expanded_logo.png" />
<img class="p-4 ms-auto" style="width:auto; max-width: 34%; object-fit:contain;" src="../../title_text.png">
</div>
<!-- main content -->
<div class="mainContent">
<!-- text -->
<div class="px-5 pt-5 pb-4 display-5 d-flex flex-column h-100">
<p>Do you have any <span class="brand">medical conditions</span> and/or <span class="brand">allergies</span>?</p>
<div class="pt-4 h-100">
<input type="text" class="text-wrap h-100 w-100 form-control align brandBorder fs-1 px-4 pt-2" placeholder="Start typing here..." id="conditions">
</div>
<p id="error" class="text-danger visually-hidden"><span class="fs-3">Please double check your entry.</span></p>
<div class="d-flex pt-4 ps-2">
<p class="brand fs-2 me-auto">Separate items with a comma. <br> e.g type 1 diabetes, coronary heart disease</p>
<input class="btn btn-dark border-0 btn-lg brandBack fs-1 px-5 mt-4 border" type="submit" value="Next" id="next">
</div>
</div>
</div>
</div>
</body>
All I needed to do was use a textarea instead of input, as input does not support multiple lines or vertical alignment.
I saw you add many CSS class to this input
text-wrap h-100 w-100 form-control align brandBorder fs-1 px-4 pt-2
Let's try to remove them and add them one by one again, you will find the problem.
I am trying to figure out how to align contents to the baseline. I am working with the bootstrap framework, and have been unable to do so.
<div class="row">
<div class="col-12">
<span class="h5">My Games</span>
<button type="button" class="btn btn-info float-right" v-b-modal.create-game>New Game</button>
</div>
</div>
Which produces this:
When I consult the bootstrap documentation, it says to do this:
<div class="d-flex align-items-baseline">...</div>
But when I do this or apply the same classes to the col-12:
<div class="row">
<div class="col-12">
<div class="d-flex align-items-baseline">
<span class="h5">My Games</span>
<button type="button" class="btn btn-info float-right" v-b-modal.create-game>New Game</button>
</div>
</div>
</div>
it results in this:
I looked at this post, which suggests flex and align-items:baseline to the row div. However when I did this, nothing happens.
Could anyone suggests to me what I am doing wrong and how I can fix it? I would like the text to be placed to the baseline, and for them to still be spread apart from one another.
I would like it to look close to this:
Thanks!
You need to remove the margin for your .h5 and use .align-items-end
span.h5 {
flex-grow: 1;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="row">
<div class="col-12">
<div class="d-flex align-items-end">
<span class="h5 m-0">My Games</span>
<button type="button" class="btn btn-info float-right" v-b-modal.create-game>New Game</button>
</div>
</div>
</div>
You can add some css & see result
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="row" style="margin: 0px;">
<div class="col-12" style="display: inline-block;width: 100%;background-color: #efefef;padding: 15px;">
<span class="h5" style="margin: 10px 0 0 0;display: inline-block;">My Games</span>
<button type="button" class="btn btn-info float-right" v-b-modal.create-game>New Game</button>
</div>
</div>
I am trying to add the fa-icon as a button inside the input as you guys can see:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="input-group">
<textarea class="form-control custom-control" rows="2" style="border-radius: 3rem;"></textarea>
<span class=""> <i class="fa fa-comments fa-2x" style="padding-top: 5px; color: #18d26e;"></i></span>
<!-- or -->
<input class="form-control custom-control" rows="2" style="border-radius: 3rem;"></input>
<span class=""> <i class="fa fa-comments fa-2x" style="padding-top: 5px; color: #18d26e;"></i></span>
</div>
The question is how to add it as a button inside the input and also have other buttons inside same input? I would like to add and have functionality to also add more then 1 button inside, like left button , right button etc.
I also tried and added this example on jsfiddle https://jsfiddle.net/s7zLf0e1/
You can't place buttons within inputs. I would recommend that you style a div or form to look like the input field like so:
https://jsfiddle.net/mattclarke/wghr6xtn/3/
Markup:
<form class="m-5 border inline-block pr-3">
<input type="text" class="p-2" placeholder="Place text in here...">
<button class="bg-blue-500 text-white rounded-full px-1">
<i class="fas fa-plus"></i>
</button>
</form>
You will need to change the CSS to fit in with your site.
This keeps the desired effect of a button within the input, although it is not.
I have a button with 1. an icon and 2. some normal text.
The problem is that the icon and the text are on different heights WITHIN the button. I thought something like this would work:
<div style="text-align: center;">
<button class="btn btn-outline-dark btn-lg">
<div class="row">
<i class="material-icons md-48">hourglass_full</i>
Some Text
</div>
</button>
</div>
it does work, but the w3c validator tells me, that
"Element div not allowed as child of element button in this context."
How are you supposed to align the elements within a button then? I didnt find a solution :S
Thanks for the help in advance!
You can take advantage of bootstrap classes, specifically flexbox
d-flex will make the button a flex box
align-items-center will center flex items vertically
Take a look
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<div class="p-5">
<button class="btn btn-outline-dark btn-lg d-flex align-items-center m-auto">
<i class="material-icons md-48">hourglass_full</i>
<span class="ml-2">Some Text</span>
</button>
</div>
I'm trying to align items in a div tag and I have tried a couple ways but failed to do so.
.
Basically this is what I have:
I tried using flex but when I align individual items to top, midlde or bottom, all 3 get aligned that way.
Is there a way I can do it using bootstrap only? and if not please help me with css. Thank you!
This is my code (the styles are in a separate file but I minimized it into the html code for this question):
<div class="card card-image" style="background-image: url(/uploads/projects/<%=user_data.projects[i]['image']%>); min-height: 200px;">
<div class="text-white text-center rgba-black-strong py-3 px-4 rounded" style=" min-height: 200px;">
<div class="--I tried flex and different aligns--">
<p class="red-text">
<i class="fa fa-pie-chart"></i>
<%=user_data.projects[i].category%>
</p>
<h6 class="font-weight-bold">
<%=user_data.projects[i].title%>
</h6>
<a class="btn btn-sm btn-red btn-rounded btn-md mb-1" data-toggle="modal" data-target="#projectModal<%=i%>"><i class="fa fa-clone left"></i> View</a>
</div>
</div>
</div>
You can use the classes d-flex, flex-column and justify-content-around to solve this:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" integrity="sha256-NuCn4IvuZXdBaFKJOAcsU2Q3ZpwbdFisd5dux4jkQ5w=" crossorigin="anonymous" />
<div class="card card-image">
<div class="d-flex justify-content-center rgba-black-strong py-3 px-4 rounded" style="min-height: 200px;">
<div class="d-flex flex-column justify-content-around">
<p class="red-text">
<i class="fa fa-pie-chart"></i>
1st item
</p>
<h6 class="font-weight-bold">
2nd item
</h6>
<a class="btn btn-sm btn-red btn-rounded btn-md mb-1" data-toggle="modal" data-target="#projectModal">
<i class="fa fa-clone left"></i> View
</a>
</div>
</div>
</div>