I want to create a special box/div for this message board which adds the top part of the cross to this project. Ideally, this solution will allow a small picture to the left of the bar and the banner/logo will occupy the space to the right of the top bar.
I cannot wrap my head around how to create two div elements where the left side is a fixed width and the right side fills the remaining browser space. link to test-site: https://bchristiancross.runboard.com
#wrapper {
position: relative;
width: 95%;
margin: 0 auto;
border: 2px solid #FF0000;
}
#header {
text-align: center;
height: 175px;
background: #FFFF80;
}
#content,
#footer {
margin-left: 175px;
border: 1px solid #0000FF;
border-left: 50px solid #0000FF;
}
#content:after {
content: '';
position: absolute;
width: 400px;
left: 0;
top: 125px;
border-top: 50px solid #0000FF;
}
<div id="wrapper">
<div id="header">
board banner/logo goes here
<h1>Your board name here</h1>
</div>
<!-- end header -->
<div id="content">
</div>
</div>
Use 'css flex', I hope it helps your question.
There is good web site to learn about CSS Flex
Following code is an example that you might want to do, I hope it answers your question.
index.html
<div id="header" class="flex_container">
<div class="flex_left">
<img alt="picture" src="">
</div>
<div class="flex_right">
board banner/logo goes here
<h1>Your board name here</h1>
</div>
</div>
main.css
.flex_container {
display: flex;
}
.flex_left{
min-width: 175px;
padding-bottom: 50px;
display: flex;
justify-content: center;
align-items: center;
border-right: 50px solid #0000FF;
}
.flex_right{
width: 100%;
}
Related
I have about the same structure. The width of the central content part is 1080px. .corner is an angle with absolute positioning that cuts off the right side of the header.
The problem is that when the screen narrows, this angle goes to the content part. I will hide it from mobile devices altogether, but on other resolutions I would like it to just go off the screen when it rests on the left side of the content part.
<div class="header">
<div class="corner"></div>
<div class="header-content">
Some kind of header content
</div>
</div>
<div class="main">
<div class="content">
Some kind of main content
</div>
</div>
My CSS
.header {
max-width: 1080px;
margin: 0 auto;
padding: 10px;
background-color: #FAAC38;
}
.corner {
width: 253px;
position: absolute;
right: 0;
border: 0 solid #f8f9fa;
border-bottom-width: 168px;
border-top-width: 0px;
border-left: 168px solid #FAAC38;
}
.main {
max-width: 1080px;
margin: 5px auto;
padding: 60px;
background-color: #fff;
border: 1px solid #e9ecef;
}
I made a gif
I have a table made with divs, using flexbox to obtain a nice table formatting of my divs.
Now I got a structure like this:
<div class="tableWrapper">
<div class="tableHeader">
<div class="tableHeaderRow">
<div class="tableHeaderCells"></div>
<div class="tableHeaderCells"></div>
</div>
</div>
<div class="tableBody">
<div class="tableBodyRow">
<div class="tableBodyCells"></div>
<div class="tableBodyCells"></div>
</div>
<div class="tableBodyRow">
<div class="tableBodyCells"></div>
<div class="tableBodyCells"></div>
</div>
<div class="tableBodyRow">
<div class="tableBodyCells"></div>
<div class="tableBodyCells"></div>
</div>
</div>
so now what I would like to achieve is to have the "tableHeader" always stay in the same position, so when the "tableBody" content is big (it could have 50rows) and doesn't fit in the browser screen, when the user scrolls down, the header follows so it's always visible.
I tried with position:fixed but then it messes up the "tableBody" content.
Here the current css:
.tableWrapper {
width: 100%;
height: 100%;
margin-top: 15px;
position: relative;
}
.tableHeader {
width: 100%;
position: relative;
}
.tableHeaderRow {
display: flex;
height: 35px;
border-bottom: 1px solid #000;
align-items: center;
}
.tableHeaderCells {
display: flex;
border-top: 1px solid #000;
border-bottom: none;
border-left: 1px solid #000;
border-right: 1px solid #000;
align-items: center;
justify-content: center;
font-weight: bold;
height: 100%;
width: 100%;
}
.tableBodyCells {
display: flex;
border-top: none;
border-bottom: none;
border-right: 1px solid #000;
border-left: 1px solid #000;
height: 100%;
width: 100%;
align-items: center;
justify-content: center;
}
.tableBody {
width: 100%;
height: 100%;
position: relative;
}
.tableBodyRow {
display: flex;
height: 50px;
width: 100%;
align-items: center;
border-bottom: 1px solid #000;
border-top: 1px solid #000;
margin-bottom: 2px;
}
here a fiddle: jsfiddle
so the final result I would like to obtain is, with a body with over 50rows, I want the user to be able to scroll down while leaving the header always on screen, and a plus would be that the "scroll size" (don't know how to call it) is equal to the rows height, meaning that when the user scrolls once, it will go down a fixed amount and exactly put a body row under the header, to avoid that when the user scrolls you get the header, and under it a cut in half body row, hope you understood what I mean!
Please check this you can use position: sticky; instead of position: sticky; please check fidle, hope it will help you
https://jsfiddle.net/06L52wm1/36/
.tableWrapper{position:relative;}
.tableHeader{position:absolute;width:100%:`}
I don't know what your issue was with position:fixed but it doesn't seem like it changes the body content.
.tableHeader {
width: 100%;
position: fixed;
background-color: #FFFFFF;
z-index:999;
}
.tableBody {
width: 100%;
height: 100%;
position: relative;
padding-top: 50px;
}
JSfiddle
There is still an issue with the width of the header though but I think you can set it by removing the the body margin from the tableHeader's width with calc()
.
This is my website: http://audunhilden.tk/projects/temp/#,
you can see my text box to the left, thats 3 divs. Can anyone help me to get another one on the same line? I cant get it to work, would be great if anyone coded a easier one too.
Not able to share my HTML or CSS,
Cant paste my CSS for some reason, you´re able to see it here:
http://audunhilden.tk/projects/temp/info.css
Here's a simple example. I did not use any of your css, as the html and those things are missing, but hopefully this can get you going:
CSS:
.container {
position: relative;
width: 500px;
background: red;
overflow: hidden; /*To get your parent to respect the floated divs*/
}
.one, .two, .three {
position: relative;
width: 33.33333333333333%; /*Because you only have 3 elements (100 divided by 3)*/
height: 100px;
float: left; /*To get them next to each other if all else fails*/
background: green;
}
HTML:
<div class="container">
<div class="one">
Div One
</div>
<div class="two">
Div Two
</div>
<div class="three">
Div Three
</div>
</div>
EDIT:
I tried to replicate your website to what I think you are trying to explain :).
Here's a quick screenshot:
Please see this HTML and CSS to replicate the image above :):
<!DOCTYPE html>
<html>
<head>
<title>Cocos - Audun Hilden</title>
<style>
body {
font-family: 'Roboto', sans-serif;
background: #36536B;
}
header {
background: #FFFFFF;
color: #919191;
padding: 15px;
line-height: 30px;
max-width: calc(770px - 30px);
border-radius: 3px;
margin: auto;
}
.container {
max-width: 770px;
margin: auto;
margin-top: 15px;
overflow: hidden;
}
.left, .right {
float: left;
overflow: hidden;
border-radius: 3px;
margin-right: 10px;
max-width: calc(50% - 5px);
}
.right {
margin-right: 0px;
}
.left-header, .right-header {
background: #58C5B3;
font-size: 10px;
padding: 15px;
color: #FFFFFF;
}
.left-text, .right-text {
background: #FFFFFF;
padding: 5px;
font-size: 15px;
}
</style>
</head>
<body>
<header>
FORSIDEN
</header>
<div class="container">
<div class="left">
<div class="left-header">
BORDER-LEFT
</div>
<div class="left-text">
One two three four
</div>
</div>
<div class="right">
<div class="right-header">
BORDER-RIGHT
</div>
<div class="right-text">
One two three four five six seven
</div>
</div>
</div>
</body>
</html>
Take some time to look at the HTML and CSS to try figure out what is going on. Once you understand, you'll never forget!
It's important to note that your doctype is also invalid. Try using <!DOCTYPE html>. Your code is all over the place too. You have html code outside of the body. The style tag should be inside the head tag, but ideally you should be using a stylesheet.
I just added display: inline; to the #tekst-sett div id in the css
and added acontainer to both inputs as you requested.
<div id="cont">
<div id="tekst-sett">
Insert text pls
</div>
<div id="tekst-sett">
Insert text pls
</div>
</div>
#tekst-sett {
padding-left: 3px;
padding-right: 3px;
padding-bottom: 3px;
background-color: #ffffff;
border-left: 1px solid #c2c2c2;
border-right: 1px solid #c2c2c2;
border-bottom: 1px solid #c2c2c2;
border-radius: 0 0 5px 5px;
position: relative;
width: 24%;
font-size: 15px;
display: inline;
}
is that what you meant?
You can Use the concept of Flex to achieve this. Here is the small example of what you are expecting
#main{
display:flex;
justify-content:space-around;
}
#sub1,#sub2{
width:100px;
height:100px;
border:1px solid;
}
<div id="main">
<div id="sub1">
</div>
<div id="sub2">
</div>
</div>
I think you should use floats, and maybe do a little research it will be easier next time if you solve it yourself!
I recommend you this article, maybe it will help you some further project:
https://css-tricks.com/all-about-floats/
I'm trying to put a logo and a sidebar next to eachother, but it just won't work. The logo container needs to be centered at the top. And the sidebar needs the be at the top-left Can you help me? I already tried float, no succes. :(
code:
<body>
<center>
<div id="logo1">
<div id="logo2"></div>
</div>
</center>
<div id="sidebar1">
<a href="https://test.com/" target="blank">
<div id="test1"></div>
</a>
</div>
</body>
CSS:
#test1 {
display: inline-block;
position: absolute;
border: 1px solid;
margin-top: 15px;
margin-left: 22px;
background-image:url('Afbeeldingen/2.png');
height: 45px;
width: 45px;
}
#test1:hover {
display: inline-block;
position: absolute;
border: 1px solid;
margin-top: 15px;
margin-left: 22px;
background-image:url('Afbeeldingen/1.png');
height: 45px;
width: 45px;
}
#sidebar1 {
display: inline-block;
position: relative;
border: 1px solid;
margin-top: -10px;
margin-left: -15px;
background-image:url('Afbeeldingen/lol.png');
height: 1080px;
width: 118px;
}
#logo1 {
display: inline-block;
position: relative;
border: 1px solid;
margin-top: 10px;
height: 100px;
width: 700px;
}
Ok, This is what you have to do :
You need to remove the display:inline-block from #logo1
And instead of just writing margin-top:10px , you need to use margin:0px auto, or you could write margin:10px auto. By this, it will center your #logo1 div.
But to center a "div" , you need to have another container(div) that wrap within your div. So that it will know, from which side to which side that it will have to be "centered".
For that reason, you will need to create another div or container around your #logo1 div, and lets assume it is called "right" (see the code below).
And for this div/container to be just beside your sidebar, it will need to have a relative position same as your sidebar. Now, you can just float both of your #sidebar1 and also your #logo1 to the left.
Thus, you dont have to use that negative margin for your sidebar anymore (remove that). If you wanted to use the negative margin, you have to use the absolute position in this case. But you will then have to restructure your whole #logo1 div which will create a lot of works.
This is the full code for your reference :
HTML code :
<div id="container">
<div id="sidebar1">
<a href="https://test.com/" target="blank">
<div id="test1">This is sidebar</div>
</a>
</div>
<div id="right">
<div id="logo1">
<div id="logo2"><This is logo</div>
</div>
</div>
</div>
And use this CSS :
#container{
width:1000px;
height:1080px;
position:absolute;
border:1px solid #000;
}
#test1 {
display: inline-block;
position: relative;
border: 1px solid;
margin-top: 15px;
margin-left: 22px;
background-image:url('Afbeeldingen/2.png');
height: 45px;
width: 45px;
}
#test1:hover {
display: inline-block;
position: relative;
border: 1px solid;
margin-top: 15px;
margin-left: 22px;
background-image:url('Afbeeldingen/1.png');
height: 45px;
width: 45px;
}
#sidebar1 {
display: inline-block;
position:relative;
float:left;
border: 1px solid;
background-image:url('Afbeeldingen/lol.png');
height: 1080px;
width: 118px;
border:1px solid red;
}
#right{
position:relative;
float:left;
margin-top:0px;
width:870px;
height:100px;
}
#logo1 {
position:relative;
border: 1px solid;
margin: 0px auto;
height: 100px;
width: 700px;
}
Do you want this ?
#test1 {
border: 1px solid;
margin-top: 15px;
margin-left: 22px;
background-image:url('Afbeeldingen/2.png');
height: 45px;
width: 45px;
}
#test1:hover {
background-image:url('Afbeeldingen/1.png');
}
#sidebar1 {
position:absolute;
border: 1px solid;
background-image:url('Afbeeldingen/lol.png');
height: 1080px;
width: 118px;
}
#logo1 {
border: 1px solid;
margin-top: 10px;
height: 100px;
width: 700px;
}
<div id="sidebar1">
<a href="https://test.com/" target="blank">
<div id="test1"></div>
</a>
</div>
<div id="logo1">
<div id="logo2"></div>
</div>
I assume this is what you want? http://jsfiddle.net/Le6PH/
You should do:
Remove the negative margins (If you don't know what you are doing, don't use negative margins)
Remove the <center> tag (This tag is deprecated since EVER)
Remove the margin of your logo
Add a wrapper div around your whole structure
Add the following CSS to that div
CSS
.wrapper{
position:relative;
width:818px; /* sidebar width + logo width */
}
Change position:relative; to position:absolute for your logo & sidebar divs.
Add top:0; for both divs
Add right:0; for the sidebar div
EDIT:
With a centered logo, like this (http://jsfiddle.net/Le6PH/1/) you'll need to change 2 things:
Add a margin-left:118px; to the logo div
Change the width of the wrapper to width of logo + margin logo + width of sidebar.
Try floating your div, it should look like this..
<div class="row">
<div id="log"></div>
</div>
<div class="row">
<div id="sidebar"></div>
</div>
css
.row{
float: left;
width: 50%;
}
I'm trying to make liquid HTML layout with header (taking all available width and 130px height), 2 columns (1: 300px width all possible height, 2: all available width after column 2 took its 300px and 15-20px margin between them).
Atm I've got this:
HTML:
<div class="wrapper">
<div class="header">
<!-- .... -->
</div>
<div class="content">
<div class="left-column">
<!-- ... -->
</div>
<div class="right-column">
<!-- ... -->
</div>
</div>
</div>
CSS:
html, body {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
min-width: 1000px;
min-height: 500px;
}
body {
font: 12px sans-serif;
background-color: #fff;
color: #000;
}
.wrapper {
height: 100%;
width: 100%;
position: relative;
}
.header {
padding: 0 30px;
height: 100px;
left: 0px;
right: 0px;
position: absolute;
border: 1px solid black;
border-top: none;
}
.content {
position: absolute;
top: 120px;
left: 0;
right: 0;
bottom: 0px;
margin: 10px 20px;
border: 1px solid black;
}
.left-column {
float: left;
width: 300px;
border: 1px solid black;
}
.right-column {
margin-left: 315px;
border: 1px solid black;
}
The question is: are there any better solutions?
Thanks.
I took your HTML and created this fiddle for you: http://jsfiddle.net/RdQJY/1/. I didn't use any of your CSS though - I just don't like positioning used in the way you are using it, so decided to write it from scratch (sorry about that). The lorem ipsum text is just there as a placeholder - if you remove it, you'll see that the divs will occupy the whole window. Hope this helps!
P.S.: the only drawback to my method of having equal-height columns is that there is no easy way to apply a bottom border to them.