I am stuck with a problem , when am trying to give background colour on my top bar its won't applied , I tried lots of time but still its won't working, please try to fix my error
This is my simple top bar code
topbar.html
<div class="header-top bg-dark" style="background-color: black;">
<div class="container-fluid bg-dark" style="background-color: black;">
<div class="left-side float-left ml-5">
<p>Search</p>
<p style="text-indent: 20px;">About Us</p>
<p style="text-indent: 20px;">Contact Us</p>
</div>
<div class="right-side float-right mr-5">
<p>Login</p>
<p style="text-indent: 20px;">Register</p>
</div>
</div>
</div>
Two problems:
Your float is breaking the layout, so you need to add the class .clearfix to the parent to fix it.
The class bg-dark adds !important, so if you want to override it, you need to do like background-color: black !important;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<div class="header-top bg-dark" style="background-color: black !important;">
<div class="container-fluid bg-dark clearfix" style="background-color: black !important;">
<div class="left-side float-left ml-5">
<p>Search</p>
<p style="text-indent: 20px;">About Us</p>
<p style="text-indent: 20px;">Contact Us</p>
</div>
<div class="right-side float-right mr-5">
<p>Login</p>
<p style="text-indent: 20px;">Register</p>
</div>
</div>
</div>
i think because you are using inline css, you could do like this
open another file for css and give it the
css file
mycolor{ background-color: black;}
you are getting other color because of the class you are using bg-dark so either you remove that from div class names or replace your codes with following lines :
<div class="header-top bg-dark" style="background-color: black !important; ">
<div class="container-fluid bg-dark clearfix" style="background-color: black !important;">
OR
<div class="header-top" style="background-color: black; ">
<div class="container-fluid clearfix" style="background-color: black;">
this !important will overwrite bg-dark attribute of the div class
Instead of using inline styles for multiple paragraph or other repeating elements, you can simply put <styles> tag and add your styles there so it will be more readable or put your styles in different file and link it to your html.
As for the code, you can try the !important ending if the style is not applied, also you need to change the color of your text
Here is an example
<div class="header-top bg-dark">
<div class="container-fluid bg-dark clearfix">
<div class="left-side float-left ml-5">
<p>Search</p>
<p>About Us</p>
<p>Contact Us</p>
</div>
<div class="right-side float-right mr-5">
<p>Login</p>
<p>Register</p>
</div>
</div>
<style>
.header-top, .container-fluid {
background-color: black !important;
}
p {
text-indent: 20px;
color: white;
}
</style>
Related
The cards html looks like this:
<div class="container-fluid">
<img src="http://clipart-library.com/img/1279251.png" style="max-width: 100px; filter: invert(1); float: left">
<h1 style="color: white;">Favourite <br>apps </h1>
<div class="row flex-row overflow-auto flex-nowrap" id="favourites" style="max-height: 400px">
<div tabindex="0" class="card" style="max-width: 18rem;" id="ytdroid2">
<img src="https://tse2.mm.bing.net/th?id=OIP.qHEnapkicCACp91KvwDYUAHaFj" class="card-img-top">
<div class="card-body" style="height: 200px;">
<h1 class="card-title" style="color: white;">
<b>Test 2</b>
</h1>
</div>
</div>
<div tabindex="0" class="card" style="max-width: 18rem;" id="ytdroid">
<img src="https://tse2.mm.bing.net/th?id=OIP.qHEnapkicCACp91KvwDYUAHaFj" class="card-img-top">
<div class="card-body" style="height: 200px;">
<h1 class="card-title" style="color: white;">
<b>Test 1</b>
</h1>
</div>
</div>
</div>
</div>
and it creates:
The background color for both the card and the card body is set in a css sheet to white with an opacity of 0.4. As you can see the width of the card is bigger than the width of the image and the card body. If i remove the row related classes from this, they are the same size however this will not work as they stack vertically. I cannot use a card deck because i want these to have a fixed width and be horizontally scrollable which doesn't seem to work with a card deck. How can I make the width of the card match the width of the image and body?
The cards should be placed inside columns.
"Rows are wrappers for columns. Each column has horizontal padding
(called a gutter) for controlling the space between them... "
Also...
"When building grid layouts, all content goes in columns. The
hierarchy of Bootstrap’s grid goes from container to row to column to
your content. "
You don't want to...
Use a col-* without a row as it's immediate parent.
Place content directly inside the row.
Regardless of how you use the grid classes (correctly or incorrectly), in your case the source of the space is padding BS applies to .card.
You can add .p-0 to the .card or otherwise set the padding to zero on the element. In the snippet below I have added .p-0 only to the first card for comparison:
div.container-fluid {
background-color: DarkSlateBlue;
}
div.card,
div.card-body {
background-color: rgba(255, 255, 255, 0.4);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<div class="container-fluid">
<img src="http://clipart-library.com/img/1279251.png" style="max-width: 100px; filter: invert(1); float: left">
<h1 style="color: white;">Favourite <br>apps </h1>
<div class="row flex-row overflow-auto flex-nowrap" id="favourites" style="max-height: 400px">
<div tabindex="0" class="card p-0" style="max-width: 18rem;" id="ytdroid2">
<img src="https://tse2.mm.bing.net/th?id=OIP.qHEnapkicCACp91KvwDYUAHaFj" class="card-img-top">
<div class="card-body" style="height: 200px;">
<h1 class="card-title" style="color: white;">
<b>Test 2 .card.p-0</b>
</h1>
</div>
</div>
<div tabindex="0" class="card" style="max-width: 18rem;" id="ytdroid">
<img src="https://tse2.mm.bing.net/th?id=OIP.qHEnapkicCACp91KvwDYUAHaFj" class="card-img-top">
<div class="card-body" style="height: 200px;">
<h1 class="card-title" style="color: white;">
<b>Test 1 .card</b>
</h1>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
I'm writing a code for website with accordion patters and can't figure out how do I remove border from the "bottom section" of the accordion pattern. I need to have borders on top section that opens the rest of accordion patter onclick. Anyone knows? Tried searching for it and could not find anything.
Here's my code :
<section id="specification" class="mt-5 pt-4">
<div class="container-fluid container-fluid-shorter">
<!--Accordion wrapper-->
<div class="accordion md-accordion accordion-1" id="accordionEx23" role="tablist">
<div class="card my-4">
<div class="card-header blue lighten-3 z-depth-1" role="tab" id="heading96">
<h4 class="text-capitalize mb-0 py-1">
<a class="text-black font-weight-light" data-toggle="collapse" href="#collapse96" aria-expanded="true"
aria-controls="collapse96">
kupnĂ typ
</a>
</h4>
</div>
<div id="collapse96" class="collapse show" role="tabpanel" aria-labelledby="heading96"
data-parent="#accordionEx23">
<div class="card-body">
<div class="row">
<div class="col-md-8">
<h6 class="font-weight-light black-text text-grey mb-5">Sponsorship</h6>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
I tried adding additional CSS such as :
.card-body{
border: none !important;
}
.collapse{
border: none !important;
}
I expect the above CSS properties to overwrite the border but it doesn't seem to make any difference. Anyone knows how can I remove the border for the section below the clickable text?
In order to remove the border, you have to target .card-header,
so the css would look like:
.card-header {
border-bottom: none !important;
}
for the bottom, you have to edit the card itself:
.card {
border: none !important;
}
please let me know if this works :)
I have the following bootstrap code:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" >
<div class="row">
<div class="col-sm-1" style="background: red;">
1
</div>
<div class="col-sm-11 align-baseline" style="background: blue; padding-left: 0;">
<h6 style="background: green;">some title:</h6>
</div>
</div>
I want the bottom of the green h6 tag to be at the bottom of the blue 11-column div tag
Is this possible? i.e. the green h6 tag should be aligned to the baseline of the blue 11-column div.
You need to remove the default bottom margin of h6 and replace it with top margin:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-sm-1" style="background: red;">
1
</div>
<div class="col-sm-11 " style="background: blue; padding-left: 0;">
<h6 style="background: green;" class="mb-0 mt-2">some title:</h6>
</div>
</div>
</div>
Or align it using flexbox and margin-top auto (still need to remove the bottom margin)
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-sm-1" style="background: red;">
1
</div>
<div class="col-sm-11 d-flex" style="background: blue; padding-left: 0;">
<h6 style="background: green;" class="mb-0 mt-auto w-100">some title:</h6>
</div>
</div>
</div>
I would like to style Bootsrap 4's card-header so that there is a heading and span vertically aligned on same line. The header should consist of a <hX> heading for expanding card's card-body and a <span> which is non-clicable and pulled to the right:
How can I ensure the "Non-clicable body summary" span appear on same line as the "Clicable header"?
.card-header h3 {
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css" rel="stylesheet" />
<div class="card">
<div class="card-header" id="headingOne">
<div class="float-right card-summary">Non-clicable body summary</div>
<a class="mb-0" data-toggle="collapse" data-target="#collapse" aria-expanded="true" aria-controls="collapse">
<h3>
Clicable header
</h3>
</a>
</div>
<div id="collapse" class="collapse" aria-labelledby="headingOne">
<div class="card-body">
<p>Some content</p>
</div>
</div>
</div>
Is this what you're looking for?
.card-header h3 {
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css" rel="stylesheet" />
<div class="card">
<div class="align-items-center card-header d-flex justify-content-between" id="headingOne">
<a class="mb-0" data-toggle="collapse" data-target="#collapse" aria-expanded="true" aria-controls="collapse">
<h3>
Clicable header
</h3>
</a>
<div class="card-summary">Non-clicable body summary</div>
</div>
<div id="collapse" class="collapse" aria-labelledby="headingOne">
<div class="card-body">
<p>Some content</p>
</div>
</div>
</div>
Removed floats and used default BS flexbox utility classes for
section.
first remove float-right class.
you can use the d-flex justify-content-between class in card-header div.
<div class="card-header d-flex justify-content-between" id="headingOne">
and also add align-self-center class. <div class="card-summary align-self-center">Non-clicable body summary</div>
Working Demo
Ref : Bootstrap utilities
Below is my code and i want the "portfolio1Info" div element row to be vertically adjacent with no space/margin to "portfolioSite" div element row. I have tried .noBottomMargin{margin-bottom:0px !important;}, .noTopMargin{margin-top:0px !important}. It doesn't seem to work and i always end up with a gap between image and the row that follows the image row
<div id="portfolio1" class="col-lg-4" style="border:solid">
<div class="row">
<div class="col-lg-12">
<img class="img-responsive" src="http://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.placekitten.com?" border="1" />
</div>
</div>
<div id="portfolio1Info" class="row">
<div class="col-lg-12">
<div style="background-color:#000000">
<h5 align="center"> Please hold 1? </h5>
<h6 align="center"><i> HTML? </i></h6>
</div>
</div>
</div>
</div>
#portfolio1Info h6 {
margin-bottom: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div id="portfolio1" class="col-lg-4" style="border:solid">
<div class="row">
<div class="col-lg-12">
<a href="www.placekitten.com" target="_blank">
<img class="img-responsive" src="http://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.placekitten.com?" border="1" />
</a>
</div>
</div>
<div id="portfolio1Info" class="row">
<div class="col-lg-12">
<div style="background-color:#000000">
<h5 align="center"> Please hold 1? </h5>
<h6 align="center"><i> HTML? </i></h6>
</div>
</div>
</div>
</div>
If you want to stick that footer at bottom, then remove the space coming due to H6 tag, by default, your h6 has some margin.
Try this code
<style type="text/css">
#portfolio1Info h5 ,#portfolio1Info h6 {
margin-top: 0 !important;
}
</style>
It works well
It's not the .row, it's the <h5> in your second row. It has a margin-top of 10px.