I'm trying to have a 100% div height so that based on the variety on screen sizes it looks good, but then I need the ul to be scrollable if the content is to large and will not fit in the screen.
HTML
<div id="category_modal_body" class="modal-body">
<div id="category_filters" class="row">
<div id="category_list" class="col-md-4">
<ul>
<li> ... </li>
</ul>
</div>
</div>
</div>
<div id="category_modal_footer" class="modal-footer">
<div id="category_selected_path"></div><div id="category_footer_buttons">
<button type="button" id="add_another_category">Tjeter</button>
<button type="button" id="add_category_path">Përfundo</button>
</div>
</div>
CSS:
#category_modal_body #category_list{
padding: 0;
height: 100%
}
#category_modal_body #category_list ul{
list-style: none;
padding: 0;
margin: 0;
height:100%;
overflow:scroll;
}
This is the result I got:
So u can see how the last buttons go over the div.
How can I fix this?
First thing I would try is putting category_modal_footer div inside category_modal_body div, like this:
<div id="category_modal_body" class="modal-body">
<div id="category_filters" class="row">
<div id="category_list" class="col-md-4">
<ul>
<li>...</li>
</ul>
</div>
</div>
<div id="category_modal_footer" class="modal-footer">
<div id="category_selected_path"></div>
<div id="category_footer_buttons">
<button type="button" id="add_another_category">Tjeter</button>
<button type="button" id="add_category_path">Përfundo</button>
</div>
</div>
</div>
Related
I am trying to have buttons centered below divs...very new at coding and working my way through courses. Ideally, the buttons would be responsive and follow the divs, wherever they may be (my code could be messy, not sure, sorry if it is :P) any tips?
.items {
height:20rem;
width:20rem;
background-color:#7FDEFF;
display:inline-block;
margin:4em;
display:center;
}
.items:hover {
background-color: #9ce5ff;
}
<section id="sale">
<div class="items"></div>
<button class="buy">Add to Cart</button>
<div class="items"></div>
<button class="buy">Add to Cart</button>
<div class="items"></div>
<button class="buy">Add to Cart</button>
</section>
</body>
</html>
You may try to wrap each one with a wrapper element (.content-wrapper).
You can check the code below.
.items {
height:20rem;
width:20rem;
background-color:#7FDEFF;
margin:4em;
}
.content-wrapper{
display:flex;
flex-direction:column;
width:20rem;
align-items:center;
}
<section id="sale">
<div class="content-wrapper">
<div class="items"></div>
<button class="buy">Add to Cart</button>
</div>
<div class="content-wrapper">
<div class="items"></div>
<button class="buy">Add to Cart</button>
</div>
<div class="content-wrapper">
<div class="items"></div>
<button class="buy">Add to Cart</button>
</div>
</section>
You can also do it without using flex, see below:
.column {
text-align:center;
margin-bottom: 1rem;
padding: .5rem;
width: 10rem;
}
.items {
width: 100%;
background-color: #7FDEFF;
padding: 40px 0px;
margin-bottom: 10px;
}
.items:hover {
background-color: #9ce5ff;
}
<section id="sale">
<div class="column">
<div class="items"></div>
<button class="buy">Add to Cart</button>
</div>
<div class="column">
<div class="items"></div>
<button class="buy">Add to Cart</button>
</div>
<div class="column">
<div class="items"></div>
<button class="buy">Add to Cart</button>
</div>
</section>
The important steps are to
have text-align: center in the parent div
define a width for the parent div
define the child-div's width as 100% (thereby spreading to parent-div's width)
provide two values for child-div's padding. The first one (40px) makes sure there is some visible vertical space in the div, the second one (0px) makes it fill out the parent div horizontally.
I want my div and navbar's width stretch all the way to the right 100% but for some reason, it stops right before it reaches it. I've added screen cap of what I see
screencap
css
.section2{
font-size: 2em;
background-color: white;
width: 100%;
height: 100%;
opacity: .75;
}
HTML
<section class="section2">
<div class="row" align="center">
<div class="col-md-12">
text
</div>
<div class="row" style="font-size:.75em" >
<div class="col-md-12" >
</div>
</div>
</div>
<br><br>
<div class="row" align="center">
<div class="col-md-12">
text
</div>
<div class="row" style="font-size:.75em">
<div class="col-md-12">text
</div>
</div>
</div>
<br><br>
<div class="row" align="center">
<div class="col-md-12">
text
</div>
<div class="row" style="font-size:.75em">
<div class="col-md-12">Text
</div>
</div>
</div>
</section>
I found the solution body and html should be set to 0 margin and padding
html, body {
margin:0;
padding:0;
}
I think the parent of your section2 isn't at 100% of your screen.
I am trying to figure out how to position a header text behind a button and when I change the z-index and the top and left attributes it doesn't change as expected. The end goal is to position that header anywhere within the col I created for the button. When I change the top and left values the text doesn't move at all.
h1{
position:relative;
top:0;
left:0;
width:0px;
height:0px;
z-index:0;
}
#home_nav {
background-color: #5680E9;
}
a{
color:#ffffff;
}
<div class="container-fluid" id="home_nav">
<div class="row">
<div class="col">
<!--<div style="position:relative;">
<img src="/STEMuli_Website/img/pen.png" alt="Pen" style="width:40%;position:absolute; left:-20px; bottom:-100px"></div>-->
<div class="col">
<h1>Help?</h1>
</div>
<div class="col">
<button type="button" class="btn btn-link" data-toggle="modal" data-target="#exampleModal"><div class="display-2 text-right ">Create
</div>
</button>
</div>
</div>
<div class="w-100">
<div class="col">
<div class="display-2">
Explore
</div>
</div>
</div>
<div class="w-100">
<div class="col">
<div class="display-2">Your Library
</div>
</div>
</div>
<!--RSS feed here-->
<div class="col-8">
<div class="feedgrabbr_widget" id="fgid_15f3fc7e5ddb0c39637a55949">
</div>
<script>
if (typeof(fg_widgets) === "undefined") fg_widgets = new Array();
fg_widgets.push("fgid_15f3fc7e5ddb0c39637a55949");
</script>
<script async src="https://www.feedgrabbr.com/widget/fgwidget.js"></script>
</div>
</div>
</div>
add a class to the element.
.myfunbutton{z-index:10;position:relative;}
<div class="col myfunbutton ">
<button t
might be better ways...
For total control, change relative to absolute in your h1 .
I have three div
Navbar
Banner
Content
What I want to do is make background of navbar full width, but all elements inside navbar have margin and center, also banner and content. So I add nav-topmost class to the div that contains navbar. But when I add this class. Three div is overlapped. Without this class, everything work fine but my navbar not full width.
Can anyone help me solve this issue? Thanks in advance !
Here is my code :
.nav-topmost
{
margin-bottom:20px;
padding:0;
height:50px;
background:#000;
}
.banner
{
height:100px;
background:#eee;
margin-bottom:15px;
}
.content
{
background:#bbb;
}
<link href="http://netdna.bootstrapcdn.com/bootswatch/3.0.0/united/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid nav-topmost">
<div class="container">
<div class="clearfix">
<div class="pull-right">
SET HOME
</div>
<div class="pull-right">
<input type="submit" value="Search" class="form-control"/>
</div>
<div class="pull-right">
<input type="text" class="form-control" />
</div>
</div>
<div class="banner">
BANNER
</div>
</div>
</div>
<div class="container">
<div class="content">
Some contents
</div>
</div>
I made some correction here and hope this is what you want.
I changed the structure and put .nav-topmost's div out of .container's div.
http://jsfiddle.net/amitv1093/z2eoxm4v/
---html---
<nav class="nav-topmost">
<div class="container">
<div class="pull-right">
SET HOME
</div>
<div class="pull-right">
<input type="submit" value="Search" class="form-control"/>
</div>
<div class="pull-right">
<input type="text" class="form-control" />
</div>
</div>
</nav>
<div class="container">
<div class="banner">
BANNER
</div>
</div>
</div>
<div class="container">
<div class="content">
Some contents
</div>
</div>
---css---
.nav-topmost
{
margin-bottom:20px;
padding:10px 0px;
background:#000;
}
Is this what you want:
.nav-topmost
{
position:relative;
top:0;
}
.container, .clearfix, .banner{
width:100%;
}
Here is the JSFiddle demo
remove nav-topmost class from container-fluid element and add it to the main navigation bar like this
<div class="container-fluid"> /* Remove nav-topmost */
<div class="container">
<div class="clearfix nav-topmost"> /* Add Here */
<div class="pull-right">
SET HOME
</div>
<div class="pull-right">
<input type="submit" value="Search" class="form-control"/>
</div>
<div class="pull-right">
<input type="text" class="form-control" />
</div>
</div>
<div class="banner">
BANNER
</div>
</div>
</div>
This is they layout of the page
Here's the code for this
<div class="newsContent row">
<div class="newsDate col-md-2">05 August 2014</div>
<div class="newsSeparator col-md-1">
</div>
<div class="newsDescription col-md-7">
<div class="row">
some dummy news
<div class="newsImage"><img alt="news2" src="/Images/News/news2.jpg">
</div>
</div>
</div>
<div class="newsActions col-md-2">
<div class="row">
<div class="col-md-4">
<button type="button" class="btn btn-default btn-lg edit-content" title="Edit the news" <span class="glyphicon glyphicon-pencil">
</span>
</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-default btn-lg delete-content" title="Delete the news">
<span class="glyphicon glyphicon-trash"></span>
</button>
</div>
</div>
</div>
</div>
Now as you can see this green line is this part
<div class="newsSeparator col-md-1">
</div>
and the class is
.newsSeparator
{
background: url('my_1X1_pixel_image.png');
background-repeat: repeat-y;
}
But it is not repeating. I just see a 1px image instead of this desired green line. Something like this.
Why is it not repeating in y, after I've set background-repeat: repeat-y;. How do I make this like the desired line that repeats along y, and stretch/size accordingly as per the parent div and the news content?
EDIT
This is not a duplicate of that. I have background image that I need to repeat along y-axis.
You could wrap news description and image into a single <article> element
Then you may assign a border-left to the new inserted element. Doing so you avoid to use empty markup for styling purpose only and you also improve the semantic of the page.
<article>
<div class="newsDescription col-md-7">
<div class="row">
...
</div>
</div>
<div class="newsActions col-md-2">
<div class="row">
...
</div>
</div>
</article>
CSS
article {
border-left: 1px green solid;
padding-left: ... /* give some space between border and contents */
}
You can set height:inherit to set child div's height same as parent div.