Bootstrap CSS Button Issue, not changing colors - html

I have a bootstrap button that looks like this:
The HTML code fr this button is this:
<button type="button" class="btn-primary.custom-btn" data-bs-toggle="modal" data-bs-target="#exampleModal">
More Info
</button>
For Some reason my CSS is not showing up. I thought it was because I had other buttons on my page and their CSS was conflicting, so I changed the class to separate them:
<button class="btn-filter active" onclick="filterSelection('all')"> Show all</button>
It was just btn and I changed it to btn-filter so I could easily tell the difference in my CSS, but I am still having trouble with the custom btn not changing to the correct color.
Here is m y CSS:
<style>
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
padding: 20px;
font-family: Arial;
}
/* Center website */
.main {
max-width: 1000px;
margin: auto;
}
h1 {
font-size: 50px;
word-break: break-all;
}
.row {
margin: 10px -16px;
}
/* Add padding BETWEEN each column */
.row,
.row > .column {
padding: 8px;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
display: none; /* Hide all elements by default */
}
/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
}
/* Content */
.content {
background-color: white;
padding: 10px;
}
/* The "show" class is added to the filtered elements */
.show {
display: block;
}
/* Style the buttons */
.btn-filter {
border: none;
outline: none;
padding: 12px 16px;
background-color: white;
cursor: pointer;
}
.btn-filter:hover {
background-color: #ddd;
}
.btn-filter.active {
background-color: #666;
color: white;
}
.slidecontainer {
width: 100%;
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 25px;
background: #E7E7E7;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
background: #4CAF50;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
background: #4CAF50;
cursor: pointer;
}
body {
padding-top: 75px;
}
.footer {
background-color: transparent;
position: fixed;
left: 0;
right: 0;
bottom: 0;
width: max-content;
display: inline-block !important;
}
.wrapper {
display: block;
}
#sidebar {
min-width: 250px;
max-width: 250px;
height: 100vh;
position: fixed;
top: 0;
left: -250px;
z-index: 99999;
background: #212529;
transition: all 0.3s;
padding: 1em;
}
#sidebar.active {
left: 0;
}
.overlay {
display: none;
position: fixed;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.7);
z-index: 9999;
opacity: 0;
transition: all 0.5s ease-in-out;
top: 0;
}
/* display .overlay when it has the .active class */
.overlay.active {
display: block;
opacity: 1;
}
#dismiss {
width: 35px;
height: 35px;
position: absolute;
/* top right corner of the sidebar */
top: 10px;
right: 10px;
color: #dc880a;
}
#sidebar .sidebar-header {
padding: 20px;
background: #212529;
}
#sidebar ul.components {
padding: 20px 0;
}
#sidebar ul p {
color: #fff;
padding: 10px;
}
#sidebar ul li a {
padding: 10px;
font-size: 1.1em;
display: block;
color: #dc880a;
}
#sidebar ul li.active>a,
a[aria-expanded="true"] {
color: #fff;
background: #6d7fcc;
}
ul ul a {
font-size: 0.9em !important;
padding-left: 30px !important;
background: #6d7fcc;
}
.btn-primary.custom-btn {
background-color: #dc880a;
border-color: #dc880a;
}
* {
padding: 0;
margin: 0;
}
</style>
I am not sure what I am missing here...

You need to adjust the css classes on your button. Specifically, class="btn-primary.custom-btn" needs to change to class="btn-primary custom-btn".
The reason is that the CSS selector .btn-primary.custom-btn means "all elements with both btn-primary and custom-btn classes" but the class actually applied to the button is a single class called btn-primary.custom-btn.
<button type="button" class="btn-primary custom-btn" data-bs-toggle="modal" data-bs-target="#exampleModal">
More Info
</button>

The reason why it doesn't pick up your style is because you have incorrect class name. You need to change the button class name from class="btn-primary.custom-btn" to class="btn-primary custom-btn". You don't need the dot when giving HTML element a class name.

Related

My CSS content keeps moving vertically on my website?

So basically I am trying to make a search engine page. The hr does not want to align in the center. On top of that when I resize the page in height it sends the text in the middle and the search bar diagonally left. I am unsure what I am doing wrong. I find positioning in CSS so so hard.
I am unsure on if I am positioning correctly. I was trying to lock my content down by using vh and vw. However I have a lot of trouble locking everything down vertically.
Live Preview" https://codepen.io/thanksfortheride136/project/editor/DYaryO
#indexbody {
background-image: url("/school.jpg");
background-size: 100% auto;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
}
/*controls size of logo link box*/
.logo a {
display: block;
height: auto;
}
li {
list-style: none;
}
/* NAVBAR STYLING STARTS */
.navbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
background-color: #2f2e2e;
color: #2f2e2e;
font-family: 'Open Sans';
z-index: 1;
}
.navbaratlus {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
background-color: transparent;
color: #2f2e2e;
font-family: 'Open Sans';
z-index: 1;
}
.nav-links a {
color: #fff;
}
/* LOGO */
.logo img {
width: 230px;
height: 75px;
}
/* NAVBAR MENU */
.menu {
display: flex;
gap: 1em;
font-size: 20px;
z-index: 1;
}
.menu li:hover {
background-color: #1a1a1a;
transition: 0.1.5s ease;
}
/*everytime i adjust sizing i usually need to adjust sizing on the dropdown menu too*/
.menu li {
padding: 25px 24px;
padding-left: 5px;
border-left: 1px solid white;
display: inline-block;
width: 200px;
z-index: 1;
}
.home {
border-left: 1px solid white;
}
/* DROPDOWN MENU */
.classes {
position: relative;
}
.dropdown {
background-color: #1a1a1a;
padding-top: 1em;
position: absolute;
/*WITH RESPECT TO PARENT*/
display: none;
top: 70px;
}
.dropdown li+li {
margin-top: 10px;
}
.dropdown li {
padding: 0.5em 1em;
width: 8em;
}
.dropdown li:hover {
background-color: #2f2e2e;
width: 100%;
}
.classes:hover .dropdown {
display: block;
}
/*RESPONSIVE NAVBAR MENU STARTS*/
/* CHECKBOX HACK */
input[type=checkbox] {
display: none;
}
/*HAMBURGER MENU*/
.hamburger {
display: none;
font-size: 24px;
user-select: none;
}
/* APPLYING MEDIA QUERIES */
#media (max-width: 768px) {
.menu {
display: none;
position: absolute;
background-color: teal;
right: 0;
left: 0;
text-align: center;
padding: 16px 0;
}
.menu li:hover {
display: inline-block;
background-color: #4c9e9e;
transition: 0.3s ease;
}
.menu li+li {
margin-top: 12px;
}
input[type=checkbox]:checked~.menu {
display: block;
}
.hamburger {
display: block;
}
.dropdown {
left: 50%;
top: 30px;
transform: translateX(35%);
}
.dropdown li:hover {
background-color: #4c9e9e;
}
}
.footercontainer {
position: fixed;
bottom: 0;
width: 100%;
height: 20px;
background-color: #2f2e2e;
border: 5px solid green;
}
.atlasbar[type=text] {
padding: 6px;
font-size: 17px;
font-family: 'open sans';
color: white;
display: block;
position: absolute;
height: 40px;
width: 35%;
z-index: 1;
top: 30vh;
left: 50vh;
right: 50vh;
box-shadow: inset 0 0 50px #000, /* inner color*/
inset 20px 0 80px #000, /* inner left short*/
inset -20px 0 80px #0ff, /* inner right short*/
inset 20px 0 300px #f0f, /* inner left broad*/
inset -20px 0 300px #0ff, /* inner right broad*/
0 0 10px #fff, /* outer color*/
-1px 0 10px #f0f, /* out left color*/
1px 0 10px #0ff; /* outer right color*/
}
::placeholder {
color: white;
}
.atlascontainer {
display: block;
height: 35vh;
width: 100vw;
position: absolute;
border: 1px solid red;
}
.title {
font-family: 'Akshar', sans-serif;
color: white;
font-size: 100px;
text-align: center;
display: block;
position: absolute;
width: 35%;
z-index: 1;
top: 10vh;
left: 50vh;
right: 50vh;
}
hr {
color: white;
display: block;
z-index: 1;
margin-top: 27vh;
margin-left: 50vw;
margin-right: 50vw;
width: 30%;
position: absolute;
}
p {
font-family: 'Open Sans', sans-serif;
color: white;
text-align: center;
display: block;
position: absolute;
width: 35%;
top: 23vh;
left: 50vh;
right: 50vh;
z-index: 1;
}
.atlasimage {
display: block;
position: absolute;
width: 50%;
height: 100%;
right: 0;
top: 0;
z-index: -1;
}
body {
height: 100vh;
}
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght#300&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Akshar&family=Open+Sans:wght#300&display=swap" rel="stylesheet">
<nav class="navbaratlus">
<!-- LOGO -->
<div class="logo">
</div>
<!-- NAVIGATION MENU -->
<ul class="nav-links">
<!-- USING CHECKBOX HACK -->
<input type="checkbox" id="checkbox_toggle" />
<label for="checkbox_toggle" class="hamburger">☰</label>
<!-- NAVIGATION MENUS -->
<div class="menu">
<li class='home'>Home</li>
<li class="classes">Classes
<!-- DROPDOWN MENU -->
<ul class="dropdown">
<li>AP CS</li>
<li>STEM</li>
<li>Media Arts</li>
<li> Physics</li>
<li>Tech 8</li>
</ul>
</li>
<li>Atlas</li>
<li>Curriculum</li>
<li>Contact</li>
</div>
</ul>
</nav>
<div class='atlascontainer'>
<input type="text" placeholder="Search.." class="atlasbar">
<h1 class='title'>ATLAS</h1>
<p>A Technology Learning Aid System</p>
<hr>
</div>
<img src="editedatlas.png" alt="" class='atlasimage'>
<div class='footercontainer'></div>

Dropdown menu html + css without JavaScript

Hello could someone please tell me why my menu does not go from page to page.
Dropdown works but when I click it doesn't go to the subpage. Anticipating the question, I don't want to use JavaScript. Buttons without dropdown menu works. If this cannot be fixed, could someone sent me a menu in similar style without JavaScript.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #333;
}
hr {
border-top: 2px dashed white;
border-bottom: none;
}
a {
text-decoration: none;
color: black;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.navbar {
height: 6vh;
display: flex;
justify-content: space-around;
align-items: center;
width: 60%;
margin: auto;
}
.dropdown {
position: relative;
}
.dropdown ul {
position: absolute;
background: #bebebe;
margin-top: 10px;
width: 200px;
height: 200px;
display: flex;
justify-content: space-around;
align-items: center;
flex-direction: column;
list-style: none;
border-radius: 5px;
opacity: 0;
pointer-events: none;
transform: translateY(-10px);
transition: all 0.6s ease;
left: 0px;
}
.dropdown li {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.dropdown li:hover {
background-color: darkslategray;
}
.navbar button,
.deco {
background: none;
border: none;
color: black;
text-decoration: none;
font-size: 18px;
cursor: pointer;
}
.navbar button:hover,
.deco:hover {
color: darkslategray;
}
.dropdown button:focus+ul {
opacity: 1;
pointer-events: all;
transform: translateY(0px);
}
.top {
text-decoration: none;
background: yellow;
border: none;
color: black;
font-size: 48px;
cursor: pointer;
border-radius: 5px;
width: 45px;
height: 45px;
align-items: center;
right: 0;
bottom: 0;
position: fixed;
}
.autor {
color: #bebebe;
font-size: 16px;
}
.printButton {
border: none;
font-size: 18px;
border-radius: 5px;
width: 80px;
height: 20px;
cursor: pointer;
color: black;
background: darkslategray;
}
#media print {
.noPrint {
display: none;
}
}
<header class="noPrint">
<img src="https://via.placeholder.com/80" alt="Logo strony" class="center">
<div class="navbar">
<button>Główna</button>
<div class="dropdown">
<button>Ciasta</button>
<ul>
<li>Biszkopt</li>
<li>Beza</li>
<li>Makowiec</li>
</ul>
</div>
<div class="dropdown">
<button>Pieczywo</button>
<ul>
<li>Chleb</li>
<li>Bułki</li>
<li>Bułki na słodko</li>
</ul>
</div>
<button>Informacje</button>
</div>
</header>
Instead of using a button, I used input of type checkbox to style the dropdown when its open and remove the style when its closed. button won't work because they require either JavaScript to add functions or be inside a form element (to act as a submit button which is not what you want here).
.dropdown {
position: relative;
display: inline-block;
}
.dropdown > .dropdown-text {
padding: 10px 20px;
}
.dropdown > input {
top: 0;
opacity: 0;
margin: 0;
position: absolute;
height: 100%;
width: 100%;
cursor: pointer;
}
.dropdown > input:checked + .dropdown-container {
transform: scaleY(1);
}
.dropdown > .dropdown-container {
transform: scaleY(0);
width: 100%;
background-color: #ffffff;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.3);
position: absolute;
}
.dropdown > .dropdown-container > a {
display: block;
text-decoration: none;
padding: 10px;
background-color: #ffffff;
color: #000000;
}
<div class="dropdown">
<div class="dropdown-text">THIS IS A DROPDOWN</div>
<input type="checkbox">
<div class="dropdown-container">
Item 1
Item 2
Item 3
</div>
</div>

CSS: Transition timing help, span filling containing element and dynamic(?) width

I've been playing around with some navigation effects for a project and I've hit a few problems I'm afraid.
Firstly, the transition timing seems a bit off. My general desire was to have the "tooltip", or link name/label, to slide out when you hover over, and then slide back in when you hover off. The idea was to have the highlight color of the icon (numbers in this case) to appear as though it's simply extending and revealing the word, and then shrinking until it's all gone. I've tried a number of variations of timing and delays, but no luck.
I'm also having issues with getting the span to fill the available space/same height of the link area. I altered the spans color to highlight this discrepancy in area.
Lastly, I've put a longer name for link 5 to demonstrate the limitation/problem with using a fixed/specific width for the span. I don't think there's anyway to achieve all that I'm hoping to as well as having a variable width that depends on the length of the text.
Here is the code I have (CodePen link below):
HTML:
<body>
<div class="navigation navbar-fixed-top">
<div class="navigation container">
<ul class="navigation nav-left">
<li>1<span class="tooltiptext">Welcome</span></li>
<li>2<span class="tooltiptext">Second</span></li>
<li>3<span class="tooltiptext">Third</span></li>
<li>4<span class="tooltiptext">Fourth</span></li>
<li>5<span class="tooltiptext">ExtraLongOneToExposeProblem</span></li>
<li>6<span class="tooltiptext">Sixth</span></li>
</ul>
</div>
</div>
</body>
CSS:
.navigation::after {
clear: both;
}
.navigation::before, .navigation::after {
display: table;
content: " ";
}
.container::after {
clear: both;
}
.container::before, .container::after {
display: table;
content: " ";
}
.navigation {
min-height: 50px;
padding-left: 0;
padding-right: 0;
list-style: none;
z-index: 1;
}
.navigation > li {
display: block;
position: relative;
}
.nav-right, .nav-right > li {
float: right;
margin: 0;
}
.nav-left, .nav-left > li {
float: left;
margin: 0;
}
.navbar-fixed-top {
position: sticky;
margin-bottom: 20px;
top: 0;
border-bottom: 1px solid black;
}
.navbar-fixed-top::before {
display: block;
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 0;
bottom: 0;
top: -142px;
background-color: #008ed0;
background-image: linear-gradient(to bottom right, rgb(0, 87, 128), rgb(0, 157, 230));
}
.container {
margin-right: auto;
margin-left: auto;
padding-right: 15px;
padding-left: 15px;
}
.tooltiptext {
display: block;
background-color: #008ed0;
opacity: 0;
width: 0;
color: white;
margin-left: 10px;
text-align: center;
z-index: 1001;
transition: width 1s ease-in-out, opacity 0.5s ease-in-out 0.5s;
}
.navigation li:hover .tooltiptext {
width: 150px;
opacity: 1;
}
body {
padding-top: 0px;
padding-bottom: 20px;
margin: 0;
}
ul, ol {
margin: 0;
padding: 0;
}
li > a {
display: inline-flex;
width: 100%;
padding: 15px 20px;
color: #fff;
text-decoration: none;
fill: white;
}
li > a:hover, li > a:focus {
background-color: #d50f67;
color: white;
fill: white;
}
*,
*::before,
*::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
Any and all help is greatly appreciated. Linking to this CodePen in the hopes someone can help.
Kind regards,
Don

CSS Float content creating whitespace and overlapping other div

I'm in the midst of creating a responsive portfolio at the moment and I'm running into a bit of trouble.
Before a certain breakpoint (css media query), the second and third paragraph in the 'About' section of my website are in floats. As the window gets smaller, the text starts to overlap the footer and eventually create a whitespace at the bottom and side. When it reaches the breakpoint, the floats are valued as 'none'.
How can I make it so that the height of the container is determined by how much content is in there (i.e. the normal behaviour)? I've tried a clearfix, but that doesn't seem to work.
https://codepen.io/webdevkid/pen/gmBVMj
HTML
<body>
<nav>
<div id="logo"><a id="logo-link" href="index.html"><span id="word-1">Potential </span><span id="word-2">Beginning</span></a><div id="menu-icon"></div></div><div class="clear"></div>
<ul id="main-links">
<li><span class="word-position">About</span></li>
<li><span class="word-position">Work</span></li>
<li class="last-child"><span class="word-position">Contact</span></li>
</ul>
</nav>
<div id="main-container">
<div id="introductory-background">
<div id="introductory-overlay">
<div id="introductory-content">
<div id="introductory-container">
<h1 id="role-header">Junior Web Developer</h1>
<h3 id="role-support-text">...but that's not all I can do</h3>
<a id="read-more" class="no-select">Read More</a>
</div>
</div>
</div>
</div>
<div id="about-section">
<br />
<br />
<div id="photo-frame">
<div id="picture"></div>
</div>
<br />
<div id="about-text-container">
<p>Hi There! My name is Ed Garbutt, a Junior Web Developer based in South Buckinghamshire, with a huge passion for all things programming.</p>
<br />
<p id="about-left-side" class="side-by-side">Sadly, I'm not like most Developer out thers. I don't drink Red Bull or Monster Cans. I'm not a fan of Start Wars. I don't read Marvel Comic Books, but I am someone who likes going outside here and then.</p>
<p id="about-right-side" class="side-by-side">All jokes aside, what you <b>will</b> get is someone who prides himself on attention to details, who will always rise to a challenge ans is constantly looking to better himself, building upon his existing knowledge of programming languages and frameworks.</p>
</div>
</div>
</div>
<footer>
<p id="footer-text">
© 2016 Ed Garbutt. All rights reserved.
</p>
</footer>
</body>
CSS
body {
margin: 0;
}
nav {
width: 100%;
height: 50px;
position: fixed;
background-color: rgb(40, 40, 40);
border-bottom-style: solid;
border-bottom-color: rgb(238, 0, 0);
border-bottom-width: 7.5px;
padding-top: 14px;
z-index: 10;
}
#logo {
position: relative;
bottom: 5px;
font-size: 30px;
padding-left: 8px;
float: left;
font-family: bebas;
}
#word-1 {
color: rgb(0, 154, 205);
}
#word-2 {
color: rgb(255, 250, 250);
}
ul#main-links {
list-style: none;
margin: 0;
padding-right: 50px;
float: right;
height: 100%;
border-bottom: 7.5px solid transparent;
display: block;
font-size: 0;
}
ul#main-links li {
display: inline-block;
text-align: center;
border-bottom-style: solid;
border-bottom-width: 7.5px;
border-bottom-color: rgb(238, 0, 0);
color: white;
font-family: arcon;
font-size: 18px;
height: 100%;
width: 90px;
position: relative;
z-index: 2;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: white;
}
a:active {
text-decoration: none;
color: white;
}
a#logo-link {
text-decoration: none;
}
a#logo-link:visited {
text-decoration: none;
color: inherit;
}
a#logo-link:active {
text-decoration: none;
color: inherit;
}
ul#main-links > a > li > span.word-position {
position: relative;
top: 5px;
}
#menu-icon {
height: 48px;
width: 48px;
display: none;
cursor: pointer;
background-image: url("../images/hamburg-white-2.png");
}
#main-container {
padding-top: 71.4px;
}
#media screen and (min-width: 656px) {
ul#main-links {
display: block !important;
}
}
#media screen and (max-width: 656px) {
nav {
height: initial;
}
#logo {
width: 100%;
float: none;
padding-left: 0;
text-align: center;
bottom: 8px;
}
#menu-icon {
display: inline-block;
/* float: right;*/
position: absolute;
right: 10px;
top: -2px;
}
ul#main-links {
display: none;
float: none;
padding-right: 0;
padding-left: 0;
width: 100%;
}
ul#main-links li {
width: 100%;
display: block;
border: none;
padding: 10px 0;
}
ul#main-links li:not(.last-child) {
border-bottom-style: solid;
border-bottom-color: rgb(238, 0, 0);
border-bottom-width: 2.5px;
}
ul#main-links > a > li > span.word-position {
top: 0px;
}
#main-container {
padding-top: 62.4px;
}
}
#media screen and (max-width: 400px) {
#logo {
bottom: 7.5px;
font-size: 23px;
padding-left: 10px;
text-align: left;
}
#menu-icon {
height: 32px;
width: 32px;
background-image: url("../images/hamburg-white-1.png");
top: 0.4px;
right: 20px;
}
#main-container {
padding-top: 52.4px;
}
}
/* ----INTORDUCTION---- */
#introductory-background {
background-image: url('../images/eternity-1024x768.jpg');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
/* min-height: 527px;*/
height: 90vh;
background-size: 100% 100%;
overflow: auto;
}
#introductory-overlay {
display: table;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
#introductory-content {
margin-left: auto;
margin-right: auto;
display: table-cell;
vertical-align: middle;
text-align: center;
}
#introductory-container {
position: relative;
bottom: 60px;
}
h1#role-header {
display: block;
position: relative;
right: 5em;
opacity: 0;
font-size: 48px;
color: rgb(255, 250, 250);
}
h3#role-support-text {
display: block;
opacity: 0;
position: relative;
top: 20px;
font-size: 30px;
color: rgb(255, 250, 250);
}
#read-more {
border-radius: 38px;
background-color: rgb(255, 250, 250);
padding: 0.5em 1.5em;
font-size: 24px;
cursor: pointer;
}
#media screen and (max-width: 656px) {
#introductory-container {
bottom: 60px;
}
h1#role-header {
font-size: 37px;
}
h3#role-support-text {
top: 15px;
font-size: 24px;
}
#read-more {
font-size: 19px;
}
}
#media screen and (max-width: 400px) {
#introductory-container {
bottom: 72.5px;
}
h1#role-header {
font-size: 28px;
}
h3#role-support-text {
top: 11px;
font-size: 20px;
}
#read-more {
font-size: 16px;
}
}
/* -------------------- */
/* -------ABOUT-------- */
#about-section {
width: 100%;
height: 500px;
background-color: rgb(131, 111, 235);
}
#photo-frame {
margin: 0 auto;
background-color: royalblue;
width: 180px;
height: 180px;
border-radius: 100px;
border-style: solid;
border-color: beige;
border-width: 7.5px;
z-index: 2;
}
#photo-frame > #picture {
width: 100%;
height: 100%;
background-image: url('../images/Ed.png');
border-radius: 100px;
}
#about-section > #about-text-container {
margin: 0 auto;
width: 80%;
}
#about-section > #about-text-container > p {
margin: 0;
text-align: center;
/* padding: 0 3rem;*/
font-size: 22px;
}
#about-section > #about-text-container > p.side-by-side {
/* display: inline-block;*/
width: 45%;
text-align: justify;
}
#about-section > #about-text-container > p#about-left-side {
float: left;
}
#about-section > #about-text-container > p#about-right-side{
float: right;
}
#media screen and (max-width: 868px) {
#about-section > #about-text-container > p.side-by-side {
/* display: inline-block;*/
width: 100%;
}
#about-section > #about-text-container > p#about-left-side {
float: none;
padding-bottom: 1.5rem;
}
#about-section > #about-text-container > p#about-right-side{
float: none;
}
}
#media screen and (max-width: 656px) {
#photo-frame {
width: 150px;
height: 150px;
}
#about-section > #about-text-container {
width: 90%;
}
#about-section > #about-text-container > p {
text-align: justify;
padding: 0 1.5rem;
font-size: 20px;
}
}
#media screen and (max-width: 400px) {
#photo-frame {
width: 125px;
height: 125px;
}
#about-section > #about-text-container {
width: 100%;
}
#about-section > #about-text-container > p {
padding: 0 0.5rem;
font-size: 18px;
}
}
/* -------------------- */
/* -------FOOTER------- */
footer {
width: 100%;
background-color: black;
}
footer > p#footer-text {
margin: 0;
text-align: center;
font-family: arial;
color: rgb(169, 169, 169);
padding: 20px;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* -------------------- */
.no-select {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
Try this:
#about-section {
width: 100%;
background-color: rgb(131, 111, 235);
}
Description
You are using #about-section id remove the height property or use height:auto, you have given a fixed height. And use float:left as well in p tag ids.
here your update code
So this boils down to your p.side-by-side definition which is set at 45%.
If you want to not have columns on small screen sizes, then the approach would be to only set that 45% value with a break-point above mobile.
Your using a non-mobile first approach that makes this stuff harder (in my opinion). The easier way to go about it is to not add any width styles to those columns, and only add the 45% and the float, once the screen is above (say) 768px. In other words your media queries will generally have min values, not max.
I think a good way to start to think mobile-first is to realise that mobile layouts use kind of "less" CSS than desktops. So you keep it simple, just using semantic html, and then add in styles as the screen size increases to start making columns etc.

css - textbox filling to width, right justify buttons, etc

In some ways, I'm still pretty new to CSS and don't "get" how things are done (is seems convoluted, and there doesn't seem to be an easy way to figure things out) - so I am hoping someone here can help me. I'll post the relevant code. I am a programmer - but can't seem to figure out how to do what I want. (BTW - are there any good tools for 'visually' editing CSS? I'm doing this purely by code).
a) I need an HTML text box to expand/contract as the browser window expands/contracts, with a 'search' image icon to the right of it.
b) I need some signup/login buttons right justified
c) I need the logo/text left justified.
So basically the flow is:
[#1 logo] [#2 menu items ] [#3 search-bar with icon] [#4 login/signup buttons]
And if the browser window expands, then #3 expands to fill in the space.
i.e.,
small desktop
[#1][#2][#3][#4]
big desktop
[#1][#2][<#3-------------------------->][#4]
ideally, I'd also like to figure out on mobile (tiny desktop) how to make it:
[#1][#4]
[#3---->]
This is the HTML I have (with other stuff removed to make it simple)
/* General CSS */
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding-top: 150px;
padding-bottom: 30px;
font-family: 'Open Sans', sans-serif;
font-size: 18px;
line-height: 1.42857143;
margin: 0;
}
ul {
list-style-type: none;
}
.clfix {
display: table;
content: " ";
clear: both;
}
.hide {
display: none;
}
/* Top bar */
.logo-separator {
float: left;
width: 1px;
border-right: 1px dashed #fff;
height: 80px;
padding-left:20px;
}
.navbar {
background-color: #124780;
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
}
.navbar .navbar-brand {
text-decoration: none;
float: left;
height: 85px;
padding: 15px 15px;
font-size: 18px;
line-height: 20px;
}
.navbar .navbar-header {
position: relative;
}
.navbar ul li a, .navbar .navbar-brand {
position: relative;
display: block;
padding: 15px;
line-height: 20px;
color: #fff;
text-decoration: none;
}
.nav.navbar-nav {
float: left;
margin: 50;
padding-left:20px;
color: #fff;
}
.navbar-nav > .separator {
padding: 15px 2px;
line-height: 20px;
}
.navbar-nav .dropdown .dropdown-menu > ul > li.separator {
padding: 5px 10px;
color: #000;
}
.navbar-nav .dropdown .dropdown-menu {
text-align:center;
display: none;
position: absolute;
background: #fff;
border-bottom: 1px solid #124780;
z-index: 999;
}
.navbar-nav .dropdown .dropdown-menu > li:hover > a {
background-color: #8fb4de;
}
.navbar-nav > li {
float: left;
}
/*
.nav.navbar-nav li > a:hover, .nav.navbar-nav > li.open a {
color: #000;
}*/
.top-buttons {
margin: 0;
padding: 0;
float:right;
}
.searchBar {
margin: 0;
padding: 0;
float:right;
border-style:solid;border-width:2px;border-color:#FF0000;
display:inline-flex;
background-color: #124780;
position: absolute;
top: 0;
right: 0;
left: 0;
}
.navbar-nav-button {
display: inline-block;
float:right;
padding-top:18px;
padding-right: 5px;
padding-left: 5px;
}
.top-buttons .btn.btn-sm {
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 7px;
display: inline-block;
margin-bottom: 0;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
width: 88px;
text-align: center;
}
.top-buttons .btn.btn-primary {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
font-weight:bold;
}
.top-buttons .btn.btn-default {
color: #333;
background-color: #fff;
border-color: #ccc;
font-weight:bold;
}
.icon-bar {
background-color: #fff;
}
.navbar-nav2 {
display: inline-flex;
width: 100%;
padding-bottom: 5px;
padding-top: 0px;
position: absolute;
left: 0;
top: 85px;
background: #fff;
height: 35px;
overflow: hidden;
}
.navbar-line {
position: absolute;
bottom:0px;
width: 100%;
height: 1px;
background-color: #000;
left: 0;
}
/* Content */
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.row {
margin-right: -15px;
margin-left: -15px;
}
.col-50 {
float: left;
width: 50%;
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
/* Panels */
.submenu {
xborder: 1px solid #ebf2f2;
border-radius: 5px;
margin-bottom: 20px;
background-color: #fff;
}
.submenu .panel-heading {
background-color: #24a3d1;
border: 11px solid #ebf2f2;
cursor: pointer;
text-align: center;
border-radius: 25px;
padding: 20px 15px;
}
.submenu .panel-heading.expanded {
border: 11px solid #ebf2f2;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.submenu .panel-heading .fa-plus, .submenu .panel-heading.expanded .fa-minus {
display: block;
}
.submenu .panel-heading.expanded .fa-plus, .submenu .panel-heading .fa-minus {
display: none;
}
.submenu .panel-heading:hover {
background-color: #166988;
}
.submenu .panel-heading .panel-title {
display: inline-block;
margin: 0;
font-size: 20px;
color: #fff;
}
.submenu .panel-heading i.fa {
font-size: 25px;
color: #fff;
}
.submenu .panel-heading i:first-child {
float: left;
}
.submenu .panel-heading i.fa-plus, .submenu .panel-heading i.fa-minus {
float: right;
}
.submenu .panel-body {
padding: 0;
overflow: hidden;
}
.submenu .panel-body.closed {
display: none;
}
.submenu .panel-body ul {
border: 1px solid #ebf2f2;
border-bottom: 12px solid #ebf2f2;
margin: 0;
padding: 0;
}
.submenu .panel-body ul li a {
display: block;
padding: 12px 8px;
color: #000;
/* border-left: 1px solid #24a3d1;
border-right: 11px solid #ebf2f2; */
border-left: 11px solid #ebf2f2;
border-right: 11px solid #ebf2f2;
border-bottom: 1px solid #ebf2f2;
text-decoration: none;
font-size: 16px;
}
.submenu .panel-body ul li a i {
font-size: 12px;
color: #24a3d1;
}
.submenu .panel-body ul li a:hover, .submenu .panel-body ul li a:hover i {
color: #fff;
background-color: #24a3d1;
text-decoration: none;
}
/* Modals */
.modal {
position: fixed;
left: 0;
top: 0;
z-index: 2000;
width: 100%;
height: 100%;
}
.modal-overlay {
position: relative;
left: 0;
top: 0;
background-color: #000;
opacity: .7;
width: 100%;
height: 100%;
}
.modal-content {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding-top: 60px;
padding-bottom: 60px;
padding-left: 20px;
padding-right: 20px;
}
.modal-body {
width: 100%;
background-color: #fff;
margin-left: auto;
margin-right: auto;
border-radius: 10px;
z-index:1000;
position:relative;
}
.modal-body .modal-row {
width: 100%;
}
.modal-body .close {
background: transparent;
border: 0;
float: right;
font-size: 20px;
color: #aeaeae;
cursor:pointer;
}
.modal-body .button-container {
width: 100%;
height: 30px;
padding: 5px 10px;
}
.modal .modal-title {
font-weight: 700;
text-align: center;
}
.modal .modal-subtitle {
text-align: center;
padding-top: 8px;
padding-bottom: 8px;
}
.modal-body .fields {
padding-top: 20px;
position: relative;
}
.modal-body .input-container {
display: block;
padding: 10px 30px;
font-size: 13px;
}
.modal-body .input {
display: block;
width: 100%;
height: 30px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 3px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
.modal-body .button {
padding: 8px 12px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
display: inline-block;
margin-bottom: 0;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
width: 100%;
}
.modal-body a.forgot {
float: right;
}
.modal-body .button.btn-primary {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
}
.modal-body .button.facebook {
background-color: #3b5998;
color: #fff
}
.modal-body .button.google-plus {
background-color: #d9534f;
color: #fff
}
.modal-body .not-member {
text-align: center;
padding-top: 30px;
}
.modal-body .horizontal-line {
padding-top: 15px;
border-bottom: 2px solid #dedede;
}
.modal-body .bottom-message {
padding: 20px;
text-align: center;
font-size: 13px;
}
.modal-body .bottom-message {
background-color: #f8f8f8;
}
.modal-body .grey {
color: #a19997;
}
.navbar-nav .dropdown-menu > li > a {
color: #fff;
background-color: #4692e6;
text-align:left;
padding: 10px 30px;
border-bottom: 1px solid #fff;
}
.navbar-nav2 a {
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
font-weight: bold;
top:220px;
}
.navbar-nav2 .custom {
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
top:220px;
}
#media (min-width: 768px) {
.container, .modal-body {
width: 750px;
}
.top-buttons {
position: absolute;
top: 10px;
/* i took this out because it was screwing things up display: inline-flex; */
display: inline-flex;
}
.navbar-toggle {
display: none;
}
.navbar-nav > li:hover > a, .navbar-nav > li.active > a {
color: #aeaeae;
}
.navbar-nav > .dropdown {
position: relative;
}
.navbar-nav > .dropdown > .fa-caret-up {
position: absolute;
bottom: -4px;
left: 50%;
transform: translateX(-50%);
color:#4692e6;
display: none;
}
.navbar-nav .dropdown-menu > li > a {
width: 250px;
}
.navbar-nav > li:hover .dropdown-menu, .navbar-nav > li:hover > .fa-caret-up {
display: block;
padding:0;
}
.modal-body .vertical-line {
position: absolute;
height: 100%;
left: 50%;
transform: translateX(-50%);
}
.modal-body .vertical-line .line-color {
width: 1px;
background-color: #eee;
height: 87%;
position: absolute;
left: 50%;
}
.modal-body .vertical-line .vertical-message{
display: block;
margin-top: 75px;
background-color: #fff;
color: #696463;
position: relative;
}
}
#media (min-width: 992px) {
.container {
width: 970px;
}
}
#media (min-width: 1200px) {
.container {
width: 1170px;
}
}
#media ( max-width: 767px) {
body {
padding-top: 110px;
}
.navbar {
background-color: #124780;
position: absolute;
}
.separator {
display: none;
}
.modal-body .vertical-line {
display: block;
width: 100%;
float: left;
padding: 10px;
position: relative;
text-align: center;
}
.modal-body .vertical-line .line-color {
position: absolute;
width: 90%;
background-color: #eee;
top: 50%;
height: 1px;
left: 5%;
}
.modal-body .vertical-line .vertical-message{
background-color: #fff;
color: #696463;
position: relative;
}
.logo-separator {
display: none;
}
.navbar {
max-height: 340px;
}
.navbar-nav, .navbar-nav .dropdown-menu, .navbar-nav2 {
display: none;
}
.navbar-nav.open, .navbar-nav .dropdown-menu.open, .navbar-nav2.open {
display: block;
}
.navbar .container {
width: 100%;
padding: 0;
margin: 0;
}
.navbar .container .navbar-header{
position: relative;
width: 100%;
}
.navbar-toggle {
position: relative;
float: right;
padding: 9px 10px;
margin-top: 8px;
margin-right: 15px;
margin-bottom: 8px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
}
.navbar-toggle .icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
background-color: #fff;
}
.navbar-nav > .dropdown > .fa-caret-up {
display: none;
}
.navbar-header:before, .navbar-header:after{
content: " ";
}
.navbar-toggle .icon-bar+.icon-bar {
margin-top: 4px;
}
.navbar .navbar-nav, .navbar .navbar-nav .dropdown-menu > ul {
margin: 0;
padding: 0;
width: 100%;
}
.navbar .navbar-nav >li>a {
background-color: #78b1eb;
}
.navbar .navbar-nav >li:hover>a {
background-color: #a6c6e6;
}
.navbar .navbar-nav >li>.dropdown-menu {
margin-bottom:0;
margin-top:0;
padding-bottom: 0;
padding-top: 0;
position: relative;
padding-left:0;
}
.navbar .navbar-nav >li>.dropdown-menu>ul>li>a {
color: #fff;
background-color: #aacef2;
text-align:left;
padding: 10px 30px;
border-bottom: 1px solid #fff;
}
.navbar .navbar-nav2 {
padding-top: 0;
position: relative;
top: 0;
height: auto;
}
.navbar .navbar-nav2 a {
display: block;
padding: 10px 15px;
border-bottom: 1px solid #aaa;
}
.navbar .navbar-nav2 a:hover {
background-color: #fff1f1;
color: #5d5aff;
}
.navbar .navbar-nav2 span.separator {
display: none;
}
.navbar ul li {
float: none;
}
.top-buttons {
position: absolute;
top: 10px;
right: 60px;
}
.col-50 {
width: 100%;
}
}
<nav class="navbar">
<div class="container clfix">
<div class="navbar-header">
<button type="button" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src=./mylogo.jpg><img src=./mytextlogo.gif></a>
<div class="logo-separator"></div>
</div>
<div id="navbar">
<ul class="nav navbar-nav">
<li class="dropdown">
Menu Item 1
</li>
<li class="separator">|</li>
<li class="dropdown">
Menu Item 1
</li>
<li class="separator">|</li>
<li class="dropdown">
Menu Item 3
</li>
<li class="separator">|</li>
</ul>
<div class="navbar-nav2">
<div class="navbar-line"></div>
<div class="container" style="width:100%" align=center>
Secondary Menu 1
Secondary Menu 2
</div>
</div>
</div><!--/.nav-collapse -->
//--------------------------------------------------------------------------------------------
/* THIS IS WHERE I WANT A SEARCH BAR WITH ICON TO EXPAND/CONTRACT BASED ON BROWSER WIDTH
//--------------------------------------------------------------------------------------------
<div class=searchBar>
<input name=something type=text width=40><img src=./searchbutton.jpg>
</div>
//--------------------------------------------------------------------------------------------
/* I WANT THESE BUTTONS 'RIGHT' JUSTIFIED HERE
//--------------------------------------------------------------------------------------------
<div >
<ul class="top-buttons" style="width:100%;border-style:solid;border-width:2px;border-color:#FF0000;float:right">
<li class="navbar-nav-button"><Button id="btn-login" class="btn btn-primary btn-sm">Log in</Button></li>
<li class="navbar-nav-button"><Button id="btn-signup" class="btn btn-default btn-sm">Sign Up</Button></li>
</ul>
</div>
</div>
</nav>
any help would be greatly appreciated!
Sounds like you will need judicious use of media queries:
#media screen and (min-width: 480px) {
body {
background-color: lightgreen;
}
}
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
You've already indicated the three device sizes you need media queries for:
small desktop
[#1][#2][#3][#4]
big desktop
[#1][#2][<#3-------------------------->][#4]
mobile
[#1][#4]
[#3---->]
Now you just need to create media queries for those three sizes and set the CSS accordingly.
Mobile: Hide #2. Maybe play with floats to get #3 to display below the other two.
Big Desktop: Change #3 width (percentage based most likely)
Small Desktop: #1, #2, #3, #4 should all have the same width (percentage based most likely)
You can then use the width property to adjust the size of buttons on these different media widths:
http://www.w3schools.com/cssref/pr_dim_width.asp