I have two div fields that are causing the window to scroll right. I don't understand how to change the weight or length so that the window is only scrolling up and down not left and right.
This is part of the navbar that deals with the dropdown menu
<span class="navbar-text" class="w-25">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Register</a>
<a class="dropdown-item" href="#">Login</a>
<a class="dropdown-item" href="#">Advertise</a>
</div>
</li>
</ul>
This is the dropdown. You can see that when dropdown it expands and you have to scroll right on the page to see the dropdown box
Here are the cards the div box for these are also too big and cause the page to scroll right
<section class="features-icons bg-white text-center">
<h1>
<center><b>Explore Rentals in Island</b></center>
</h1>
<div class="card-deck">
<div class="card">
<img class="card-img-top" src="./img/home-icon.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Name</h5>
<p class="card-text">Location</p>
<p class="card-text">Price</p>
</div>
</div>
<div class="card">
<img class="card-img-top" src="./img/home-icon.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Name</h5>
<p class="card-text">Location</p>
<p class="card-text">Price</p>
</div>
</div>
<div class="card">
<img class="card-img-top" src="./img/home-icon.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Name</h5>
<p class="card-text">Location</p>
<p class="card-text">Price</p>
</div>
</div>
</div>
<br>
<br>
<button type="button" class="btn btn-primary btn-lg">View More</button>
</section>
Image of the nav bar error
Image of the cardbox error
Consider this code snippet.
section.features-icons.bg-white.text-center{
overflow: hidden;
width: 100%;
}
[aria-labelledby="navbarDropdownMenuLink"]{
margin-left: -53px;
}
Here are the two contributing factors to why your dropdown menu list is so wide:
1) In the dropdown-menu class, the min-width is set to 10rem
2) In the dropdown-item class, the left right padding is set to 1.5rem
If you go to DevTools and disable these two properties, the dropdown will fit within your browser again, but probably a bit too tight around the list items texts.
I would create my own css classes to
1) set min-width of dropdown-menu class to 0rem
2) reduce the left right padding of dropdown-item to something that looks nice but not too wide
I quickly scribbled this together:
.fix-min-width {
min-width: 0;
}
.fix-padding {
padding: 0.25rem 0.75rem;
}
Hope this helps.
Related
I have a projects section part of my portfolio. I alternate between description on left/image on right to image on left/description on right. I have been painstakingly trying to make this responsive, but I cannot think of what to do to fix this. I want the image on top and the text below on every project when viewed on a smartphone.
This is the HTML for the projects section:
<section id="projects">
<div class="container">
<div class="row projects">
<h1>My Projects</h1>
<div class="col project-desc-left">
<h2>Tindog</h2>
<p>An landing page for the Tindog app. A twist on a typical dating app. Created with Bootstrap 5 and HTML/CSS utilizing Bootstrap grids.</p>
<i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> <i class="fab fa-bootstrap"></i><br>
<a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/TinDog-WebDevBootcamp/" role="button" target="_blank">Live Site</a>
<a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/TinDog-WebDevBootcamp" role="button" target="_blank">Github Repo</a> </div>
<div class="col col-lg-6 col-sm-12 project-img-right">
<img class="project-img" src="assets/tindog.png"/>
</div>
</div>
<div class="row projects">
<div class="col">
<img class="project-img" src="assets/nftcard.png"/>
</div>
<div class="col project-desc-right">
<h2>NFT Preview Card</h2>
<p>An preview card page created with HTML/CSS.</p>
<i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> <br>
<a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/nft-preview-card-component-main/" role="button" target="_blank">Live Site</a>
<a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/nft-preview-card-component-main" role="button" target="_blank">Github Repo</a> </div>
</div>
<div class="row projects">
<div class="col project-desc-left">
<h2>3-Card Column</h2>
<p>A preview card of vehicle options created with HTML/CSS.</p>
<i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> </i><br>
<a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/3-column-preview-card-component-main/" role="button" target="_blank">Live Site</a>
<a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/3-column-preview-card-component-main" role="button" target="_blank">Github Repo</a>
</div>
<div class="col project-img-right">
<img class="project-img" src="assets/3colcard.png"/>
</div>
</div>
</div>
</section>
I used Bootstrap 5 and I tried to use col-xs-12 but it didn't look right and it also completely messed up the desktop view. The laptop view looks exactly how I want it to look, it's just every other sizing that it completely wrong.
This is the CSS:
/* Projects */
#projects {
width: 100%;
}
#projects h1 {
text-align: center;
}
.projects {
margin-left: 0;
}
.project-img{
width: 300px;
}
.project-desc-left {
margin: 5rem;
width: 320px;
}
.project-desc-right {
}
}
I have been trying to tweak the code for days, but I have barely made any progress.
This is the laptop view of the projects section
This is the mobile view of the projects section
You should be able to do it using Bootstrap 5 Column Ordering without adding any extra CSS. You can add these classes to your Col's and they will appear on the page in the order given no matter their physical place in your HTML.
General useage.
.order-1
.order-2
.order-3
.order-4
.order-5
Ordering according to screen size. In this exammple, the Column will show 1st on SM screens, it will show second on MD screens and third on LG screens.
.order-sm-1
.order-md-2
.order-lg-3 etc etc etc
You can also specify items to be unordered or ordered-first and ordered-last. Here are the docs for everything here....
https://getbootstrap.com/docs/5.0/layout/columns/#order-classes
I have a link button that I need to place to the right of a div. Adding float-left on the div and float-right on the link button does not do it. What am I doing wrong?
https://jsfiddle.net/3v2s4c50/
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">Today and Tomorrow</div>
<div class="card-body">
<div class="float-left">Someone somewhere is waiting for you.</div>
<a role="button" href="google.com" class="float-right btn btn-primary"> Login</a>
</div>
</div>
</div>
<div class="col">
2 of 2
</div>
</div>
</div>
remove floats and add:
.card-body{
display: flex;
justify-content: space-between;
align-items: center;
}
<div class="card-body d-flex">
<div class="flex-fill">Someone somewhere is waiting for you</div>
<a role="button" href="google.com" class="flex-fill btn btn-primary"> Login</a>
</div>
Well, it is doing it. But the portion of the screen that is showing the results is not wide enough to show both the div with the text and the button in the same row.. then it breaks down.
If you change the text to something smaller, like 'Someone is waiting' you can see the button floating right :)
You can also set a fixed width for your text div (currently it is expanding based on the content).
<div class="card-body">
<div class="float-left" style="width: 50%;">Someone somewhere is waiting for you</div>
<a role="button" href="google.com" class="float-right btn btn-primary"> Login</a>
</div>
You can add your link to a div with any class. Then add style "text-align: right;" into your div like this:
.my-link {
text-align: right;
}
.
<div class="my-link">
<a role="button" href="google.com" class="float-right btn btn-primary"> Login</a>
</div>
.
I hope this will be useful.
How can I display page content according to the button I click?
I would like that on entering the page it presents the HTML of a button, but if you click on the other button the page loads another HTML.
I made a very simple example, and I would like the page to load the html inside the container class and then click on another button to load the content of the container-fluid class.
Sorry if I was confused.
Thanks!
My simple example
<li class="nav-item">
<a class="Grelha">
<img src="http://icons.iconarchive.com/icons/hopstarter/button/128/Button-Close-icon.png" style="width:30px; height:30px; cursor:pointer" >
</a>
</li>
<li class="nav-item">
<a class="Vquadrado">
<img src="http://icons.iconarchive.com/icons/hopstarter/button/128/Button-Play-icon.png" style="width:30px; height:30px cursor:pointer">
</a>
</li>
<div class="container">
<div class="row text-center text-lg-left tab-pane">
<div class="col-sm-2">
<a href="#" class="d-block mb-4 h-100">
<img class="Images" src="https://source.unsplash.com/pWkk7iiCoDM/400x300" alt="">
<div class="ImageText"> Name</div>
</a>
</div>
<div class="col-sm-2">
<a href="#" class="d-block mb-4 h-100">
<img class="Images" src="https://source.unsplash.com/aob0ukAYfuI/400x300" alt="">
<div class="ImageText"> Name</div>
</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="d-flex flex-row flex-wrap" style="margin-left: 3px;">
<div class="d-flex flex-column">
<a>
<img src="https://images.unsplash.com/photo-1485963631004-f2f00b1d6606?auto=format&fit=crop&w=668&q=80" class="img-fluid Vimages">
<div class="VimageText"> Name1</div>
</a>
<a>
<img src="https://images.unsplash.com/photo-1502865787650-3f8318917153?auto=format&fit=crop&w=334&q=80" class="img-fluid Vimages">
<div class="VimageText"> Name1</div>
</a>
</div>
</div>
</div>
You can toggle container with all styles which makes it visible or not.
For example:
display:none;
visibility: hidden;
const button1 = document.querySelector('.toggle-first');
const button2 = document.querySelector('.toggle-second');
const firstContainer = document.querySelector('.first');
const secondContainer = document.querySelector('.second');
button1.addEventListener('click', () => {
firstContainer.style.display = 'block'; // Or visibility: visible or other style
secondContainer.style.display = 'none';
});
button2.addEventListener('click', () => {
secondContainer.style.display = 'block'; // Or visibility: visible or other style
firstContainer.style.display = 'none';
});
<div class="container first">
<h1> First container </h1>
</div>
<button class="toggle-first"> Toggle first container </button>
<div class="container second">
<h1> Second container </h1>
</div>
<button class="toggle-second"> Toggle second contianer </button>
I am trying to learn the basics of bootstrap for responsive websites. When I put elements into the "row" class then there is not any margins or padding to the elements and no free space, but with elements such as jumbotron and the navbar then there seems to be padding i cant get rid of on the left and right side.
Any help would be appreciated.
<nav class="navbar navbar-expand-lg navbar-expand-md">
<a class="navbar-brand" href="#">lorem ipsum</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">about</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">contact</a>
</li>
</ul>
</div>
</nav>
<div class="jumbotron jumbotron-fluid" style="background-image:url(images/hero-image.jpg)">
<div class="container-fluid">
<h1 class="display-4">lorem ipsum</h1>
<p class="lead">lorem ipsum</p>
</div>
</div>
<div class="row newsletter">
<p class="col-lg-6 col-md-6 col-sm-6 col-xs-12">subscribe to our newsletter</p>
<form class="col-lg-6 col-md-6 col-sm-6 col-xs-12 newsForm">
<input type="email" placeholder="enter your email..." class="box">
<button type="submit" class="button">></button>
</form>
</div>
Boostrap by default apply padding on the navbar you can remove right and left padding by simply doing that:
.navbar.custom-navbar {
padding-left: 0rem !important;
padding-right: 0rem !important;
}
apply custom-navbar class on <nav> element.
To remove jumbotron left and right padding remove <div class="container-fluid"> which is inside jumbotron like that:
<div class="jumbotron jumbotron-fluid" style="background-image:url(images/hero-image.jpg)">
<h1 class="display-4">odtom.com</h1>
<p class="lead">a site showcasing everything odt.</p>
</div>
Also to remove horizontal scroll from the page place the row inside conatiner-fluid.
<div class="container-fluid">
<div class="row newsletter">
<p class="col-lg-6 col-md-6 col-sm-6 col-xs-12">subscribe to our newsletter</p>
<form class="col-lg-6 col-md-6 col-sm-6 col-xs-12 newsForm">
<input type="email" placeholder="enter your email..." class="box">
<button type="submit" class="button">></button>
</form>
</div>
</div>
I'm not sure if this will answer your question, but the left and right paddings in the jumbotron element are coming from the ".container-fluid" class. It seems that you are targeting the container with the ".jumbotron-fluid" class, which is the one currently set to padding-left and right to 0px.
Just target this class to remove or amend the paddings if that's what you need.
.container-fluid {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
I have several issues laying out a website UI using Twitter's Bootstrap grid.
First off, here is the jsFiddle for my UI mockup.
I've explored the UI layout using Firebug, and things just don't seem correct. I set up a centered div (not using offset*, but actually maintaining centeredness in page regardless of window size by utilizing my centeredDiv class that I defined) which contains all accordion and the white rectangle div where the content will go.
The accordion and the content div are span2 and span8 classes, respectively. So they add up to fill up the space of their parent div, a div of class span10.
The issues are as follows:
The bottom of the background for the accordion and the bottom of the white, content rectangle are not lining up.
The bottom yellow div containing the church information isn't lined up properly with the white content div.
The text within the bottom yellow div isn't centered horizontally. I need it to be.
I really appreciate the help!
JSfiddle for you see it in action
Issue 1 : Accordion background and white background are not lining up because you have set the wrong height for accordion , it has to be height:661px .
Issue2 : It can be resolved by modifying the way you have arranged columns. Use the footer inside the main row and after the content div.
<!--Menu and Content-->
<div class="row" id="rowEntirePage">
<div class="span10 centeredDiv" id="divContentStage">
<div class="row" id="rowContentStage">
<!--Menu-->
<div class="span2 accordion" id="menuAccordion">
<!--MINISTRIES-->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseOne"> MINISTRIES </a> </div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
<ul class="nav nav-pills nav-stacked">
<li class="active">WORSHIP </li>
<li>CHILDREN </li>
<li>YOUTH </li>
<li>WOMEN </li>
<li>DISCIPLESHIP </li>
<li>MEDIA/TECH </li>
</ul>
</div>
</div>
</div>
<!--About Us -->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseTwo"> ABOUT US </a> </div>
</div>
<!--THE TEAM -->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseTwo"> THE TEAM </a> </div>
</div>
<!--EVENTS -->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseTwo"> EVENTS </a> </div>
</div>
<!--SMALL GROUPS-->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseTwo"> SMALL GROUPS </a> </div>
</div>
<!--MEDIA CENTER-->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseTwo"> MEDIA CENTER </a> </div>
</div>
<!--BLOG -->
<div class="accordion-group">
<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
href="#collapseTwo"> BLOG </a> </div>
</div>
</div>
<!--Content-->
<div class="span8" id="divContent"></div>
<!--Contact Info-->
<div id="rowContactInfo" class="span8">
<div id="divContactInfo">
<p id="paragraphContactInfo">Church Name / Address / Town, State Zip Code Phone # / <a>Email Us</a> <br>
<a>Maps& Directions</a> </p>
</div>
</div>
</div>
And specifying the following property to the contact div :
#rowContactInfo {
background: linear-gradient(#F4D987, #FFFFFF) repeat scroll 0 0 transparent;
color: #FF0000;
height: 75px;
margin: 0;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
vertical-align: top;
}
Issue 3 : I dont see any issue there . can you show me a picture of how you want it .
Update: Issue 3 : Please write styles and format your footer list properly . As in current representation it is mere text .
Hint : If anything doesnt align when you resize , its probably because you have to write media queries for your custom styles the following way for different resolution :
#media (min-width: 768px) and (max-width: 979px) {
}
#media (max-width: 767px) {
}
#media (max-width: 480px) {
}
Just put your custom styles for a particular section that doesnt look good in the required resolution