How can i make it tidy? - html

the work waiting to be done
I want them to be fixed on size; like a table without shared borders.
Here s my html and css codes:
.leftsubstancelist {
padding-top: 40px;
border-top: 2px solid #003333;
width: 39%;
float: left;
}
.rightsubstancelist {
padding-top: 40px;
border-top: 2px solid #003333;
width: 39%;
float: right;
}
.leftsubstancelist figure {
border: 3px solid #003333;
}
.rightsubstancelist figure {
border: 3px solid #003333;
}
figure img {
max-width: 80%
}
<section class="leftsubstancelist">
<figure>
<img src="img/active_substance/vankomisin.png" alt="Vankomisin Hidroklorür" align="center">
<figcaption>Vankomisin Hidroklorür</figcaption>
</figure>
<br>
<figure>
<img src="img/active_substance/imipenem_silastatin.png" alt="İmipenem / Silastatin" align="center">
<figcaption>İmipenem / Silastatin</figcaption>
</figure>
</section>
<section class="rightsubstancelist">
<figure>
<img src="img/active_substance/ertapenem.png" alt="Ertapenem" align="center">
<figcaption>Ertapenem</figcaption>
</figure>
<br>
<figure>
<img src="img/active_substance/teikoplanin.png" alt="Teikoplanin" align="center">
<figcaption>Teikoplanin</figcaption>
</figure>
</section>
I ve tried, display:box, align:center and some other related stuff but couldn't manage to tidy them up.
Thanks for your help!

Use flexbox.
When you want all rows to be of a continuous height, you could leave out align-items or set it to stretch. Otherwise you could use align-items: flex-start when you want them to have an individual height but rendered at top.
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
section {
display: flex;
justify-content: space-between;
/* Uncomment the following line, if the
rows cell can have different heights */
/* align-items: flex-start; */
flex-wrap: wrap;
border-top: 2px solid #003333;
padding: 20px;
}
figure {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
border: 3px solid #003333;
width: calc( 50% - 40px );
margin: 20px;
}
figure img {
width: 100%;
height: auto;
}
<section>
<figure>
<img src="http://via.placeholder.com/320x140" />
<figcaption>Vankomisin Hidroklorür</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/320x160" />
<figcaption>İmipenem / Silastatin</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/320x180" />
<figcaption>Ertapenem</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/320x120" />
<figcaption>Teikoplanin</figcaption>
</figure>
</section>

Try below:
<style>
.divSquare1{
width:45%; height:200px; margin:4px; border:1px solid black; float: left
}
.divSquare2{
width:45%; height:200px; margin:4px; border:1px solid black; float: right
}
.space{
width:5%;
}
</style>
<div class="divSquare1">
<figure>
<img src="img/active_substance/vankomisin.png" alt="Vankomisin Hidroklorür" align="center">
<figcaption>Vankomisin Hidroklorür</figcaption>
</figure>
</div>
<div class="divSquare2">
<figure>
<img src="img/active_substance/imipenem_silastatin.png" alt="İmipenem / Silastatin" align="center">
<figcaption>İmipenem / Silastatin</figcaption>
</figure>
</div>
<div style='clear:both' class="space"></div>
<div class="divSquare1">
<figure>
<img src="img/active_substance/ertapenem.png" alt="Ertapenem" align="center">
<figcaption>Ertapenem</figcaption>
</figure>
</div>
<div class="divSquare2">
<figure>
<img src="img/active_substance/teikoplanin.png" alt="Teikoplanin" align="center">
<figcaption>Teikoplanin</figcaption>
</figure>
</div>

Set a static height for your figure element. This will make them all have the same height and spacing. I believe this will solve your issue but your question was vague.
figure {
height: 150px;
}

Related

image redirect Centered

I'm new and I cant align my social redirect images to be centered to the "contact me" header. Text align doesn't work and other solutions I found for my problems just puts it in order vertically.
<link rel="stylesheet" href="styles.css">
<style>
.feature {
display: inline-block;
margin: 0px;
padding: 0px;
text-align: center;
}
.feature figure {
display: inline-block;
position: relative;
}
.resize {
text-decoration: none;
width: 128px;
height: 128px;
display: inline-block;
}
</style>
</head>
<body>
[HEADER]
<h1>Contact Me!</h1>
<section class="feature">
<figure>
<a href="url">
<img class="resize" src="images/discord.png" alt="Discord"></a>
<figcaption></figcaption>
</figure>
<figure>
<a href="url">
<img class="resize" src="images/insta.png" alt="Instagram"></a>
<figcaption></figcaption>
</figure>
</section>
</body>
</html>
Play around with the margins in .feature figure. I changed the size of the images and added a border to them so i could see what was going on.
.feature {
display: inline-block;
margin: 0px;
padding: 0px;
text-align: center;
}
.feature figure {
border: 1px solid #ccc;
display: inline-block;
margin: 0 8px;
}
.resize {
text-decoration: none;
width: 64px;
height: 64px;
display: inline-block;
}
[HEADER]
<h1>Contact Me!</h1>
<section class="feature">
<figure>
<a href="url">
<img class="resize" src="images/discord.png" alt="Discord"></a>
<figcaption></figcaption>
</figure>
<figure>
<a href="url">
<img class="resize" src="images/insta.png" alt="Instagram"></a>
<figcaption></figcaption>
</figure>
</section>

Why won't my <span> center vertically?

I've tried everything, but it seems like this span just won't do anything I tell it to. No applied properties change its vertical position, but horizontal properties do.
I've followed all the recommendations from this guide: https://css-tricks.com/centering-css-complete-guide/
Code:
#header{
height: 50px;
width: 100% - 50px;
padding: 0px 25px 0px 25px;
background-color: #00A680;
}
#header-right-icon-div > img{
height: 20px;
display: inline;
padding: 15px 10px 15px 10px;
}
#menu-join-button{
}
<div id="header">
<div id="header-right" style="float: right;">
<div id="header-right-icon-div">
<img src="briefcase_icon.svg" alt="">
<img src="notification_icon.svg" alt="">
<img src="profile_icon.svg" alt="">
<img src="search_icon.svg" alt="">
<span id="menu-join-button">hello</span>
</div>
</div>
</div>
Even top or bottom margins and padding don't affect it at all... but side margins do...
What is the issue here, why does this menu-join-button have a mind of it's own? How do I center the span in that green header?
Verticle align middle Way:
* {
box-sizing: border-box;
}
#header{
width: 100%;
padding: 0px 25px 0px 25px;
background-color: #00A680;
}
#header:after {
content: '';
display: table;
clear: both;
}
#header-right{
float:right;
padding: 10px 25px 10px 25px;
background-color: #00A680;
}
#header-right-icon-div > img{
display:inline-block;
vertical-align: middle;
padding: 0px 10px 0px 10px;
}
#menu-join-button{
}
<div id="header">
<div id="header-right">
<div id="header-right-icon-div">
<img src="http://via.placeholder.com/30x30" alt="">
<img src="http://via.placeholder.com/30x30" alt="">
<img src="http://via.placeholder.com/30x30" alt="">
<img src="http://via.placeholder.com/30x30" alt="">
<span id="menu-join-button">hello</span>
</div>
</div>
</div>
Flex Way:
* {
box-sizing: border-box;
}
#header{
width: 100%;
padding: 0px 25px 0px 25px;
background-color: #00A680;
display: flex;
justify-content: flex-end;
align-items:center;
}
#header-right{
padding: 10px 25px 10px 25px;
background-color: #00A680;
}
#header-right-icon-div {
display: flex;
align-items:center;
}
#header-right-icon-div > img{
padding: 0px 10px 0px 10px;
}
<div id="header">
<div id="header-right">
<div id="header-right-icon-div">
<img src="http://via.placeholder.com/30x30" alt="">
<img src="http://via.placeholder.com/30x30" alt="">
<img src="http://via.placeholder.com/30x30" alt="">
<img src="http://via.placeholder.com/30x30" alt="">
<span id="menu-join-button">hello</span>
</div>
</div>
</div>

need logo in center of page section excluding left sidebar in squarespace

website :https://wells-demo.squarespace.com/
Need logo in center of page section excluding left sidebar(header) in squarespace WELLS template on all format mobile,desktop etc.I am trying to figure out but no result.following is my code
$(document).ready(function(){
$('#headerWrapper #header ').after('<div id="logo1" data-content-field="site-title"><h1 class="logo image" data-shrink-original-size="23" style="letter-spacing: 0.0869565em;"><img src="//static1.squarespace.com/static/5adfd10929711421a9b29d21/t/5adfdbac562fa79909bad158/1524908392416/?format=750w" alt="L ETO BRIDAL" width="130" height=50"></h1></div>');
});
#logo{display:none;}
#headerWrapper{top:4px!important}
#logo1 h1 a img {
height:70px!important;
}
#logo1 {
left: 300%;
position: absolute;
text-align: center !important;
top: 10px !important;
transform: translateX(-50%);
Based on your current CSS, this should do it:
#logo {
width: 100%;
text-align: center;
}
#media (min-width: 801px) {
#logo {
position: fixed;
width: calc(100% - 340px);
top: 0;
margin-left: 240px;
box-sizing: border-box;
background-color: #ffffff85;
padding: .5rem 0;
border-bottom: 1px solid #fff;
}
}
Note: in current form, your question is not really useful to future visitors.
You can read the structure i made below using w3.css from w3schools. I have given a border colour to every div so you can see the boundary of that div and it will make it easy to learn for you.
.outer
{
border:1px solid red;
min-height:100px;
width:100%;
}
.inner-left
{
border:1px solid green;
}
.inner-right
{
border:1px solid blue;
}
.centetr
{
text-align:center;
}
.photo
{
width:95%;
margin:0px auto;
height:40px;
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div class="w3-container outer">
<!--left side-->
<div class="w3-quarter inner-left">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
</ul>
</div>
<div class="w3-rest inner-right">
<div class="w3-container w3-margin-bottom centetr">
NAME
</div>
<div class="w3-container">
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
</div>
</div>
</div>

Can't get photos to align next to each other in div

Here is my code: http://pastebin.com/pDkM4FQi
#img1,
#img2,
#img3,
#img4 {
display: inline-block;
height: 100%;
}
#navBar {
background-color: white;
border: 1px solid white;
border-radius: 15px;
display: inline-block;
height: 100px;
margin: auto;
margin-top: 50px;
width: 1200px;
}
#navSplitter {
background-color: gray;
display: inline-block;
height: 80px;
margin-left: 20px;
margin-right: 20px;
width: 3px;
}
<div id="navBar">
<div id="navSplitter" style="background-color: black;" />
<img id="img1" src="img1.png" />
<div id="navSplitter" />
<img id="img2" src="img2.png" />
<div id="navSplitter" />
<img id="img3" src="img3.png" />
<div id="navSplitter" />
<img id="img4" src="img4.png" />
</div>
I can't get the images to line up in the navBar div. I tried everything I know about code, and even looked up some stuff but never found what I need to get these images to go on there with the splitters in between each picture.
How about putting all of the images in just one <div> and then add a left-padding and right-padding to the images? This way you don't have to deal with the alignment of the images that much.
Please note that id tags are unique. You don't use them everywhere in the html file. Use class if you need
The issue is in your HTML. There is no concept of self closing div tags in HTML 4.x.
change this <div id="navSplitter"/> to <div id="navSplitter"></div>.
or my suggestion is to use <span></span> tag to add splite because span is by-default inline-block element.
Hope this would help your issue.
Try this:- remove margin-left: 20px from #naviSplitter
<head>
<style>
#img1, #img2, #img3, #img4 {
display: inline-block;
height: 100%;
}
#navBar {
background-color: white;
border: 1px solid white;
border-radius: 15px;
display: inline-block;
height: 100px;
margin: auto;
margin-top: 50px;
width: 1200px;
}
#navSplitter {
background-color: gray;
display: inline-block;
height: 80px;
/*margin-left: 20px;*/
margin-right: 20px;
width: 3px;
}
</style>
</head>
<body>
<div id="navBar">
<div id="navSplitter" style="background-color: black;"/>
<img id="img1" src="img1.png"/>
<div id="navSplitter"/>
<img id="img2" src="img2.png"/>
<div id="navSplitter"/>
<img id="img3" src="img3.png"/>
<div id="navSplitter"/>
<img id="img4" src="img4.png"/>
</div>
</body>
divs aren't a self closing tag, which you are doing, therefore invalid HTML and by consequence the images are not working as expected.
So, I advise you to forget using div for splitting the images and just use a HTML list and then using a pseudo element ::before instead.
And to align, you need vertical-align:top because inline-block is baseline by default
#navBar {
background-color: white;
border: 1px solid white;
border-radius: 15px;
display: inline-block;
height: 100px;
margin: auto;
margin-top: 50px;
width: 1200px;
}
ul {
font-size: 0
}
li {
display: inline-block;
vertical-align: top;
height: 100%;
margin: 0 5px
}
li::before {
background-color: gray;
display: inline-block;
vertical-align: top;
height: 100px;
left: -5px;
width: 3px;
content: "";
position: relative
}
<div id="navBar">
<ul>
<li>
<img id="img1" src="//dummyimage.com/100x100" />
</li>
<li>
<img id="img2" src="//dummyimage.com/100x100" />
</li>
<li>
<img id="img3" src="//dummyimage.com/100x100" />
</li>
<li>
<img id="img4" src="//dummyimage.com/100x100" />
</li>
</ul>
</div>
Maybe you would rather something like this.
<div id="nav-bar">
<img src="http://dummyimage.com/80&text=1" alt="">
<img src="http://dummyimage.com/80&text=2" alt="">
<img src="http://dummyimage.com/80&text=3" alt="">
<img src="http://dummyimage.com/80&text=4" alt="">
</div>
Don't worry about closing tags for img elements anymore. But do make sure you write something descriptive in the alt attribute about what the image content is for people with disabilities.
html {
font-size: 16px;
}
I'm using rems to do most measurements. rems are based off of a base font-size. So we tend to set it in the html element. I think 16px is a good standard these days. 1rem therefore is 16px.
Using measurements like this allows you to arrange things relatively. You could also interchange with ems if you wanted to. They are based off of the parent element font-size.
#nav-bar {
max-width: 1200px;
width: 100%;
margin: 2rem auto;
text-align: center;
background-color: white;
border-radius: 1rem;
display: inline-block;
padding: .5rem;
}
#nav-bar img {
display: inline-block;
}
#nav-bar img:not(:last-child) {
margin-right: 1rem;
padding-right: 1rem;
border-right: 3px solid gray;
}
Instead of using an HTML element for aesthetics, we can push that into the CSS completely.
I use a right border on those navigation images and make use of the not pseudo-class combined with last-child as :not(:last-child) which selects all the images except the last one. So you don't see the right border at the end.
Your HTML is not valid. div tags cannot be closed this way.
<div />.
div tags are properly used this way.
<div></div>
Due to the lack of closing tags, your images and splitters are nested. This happens because your browser does not know how to display your page since the opened/closed tags don't match up. It is then trying to fix your code by adding a bunch of closing tags at the bottom of the code, one closing tag for each opened one that was not closed.
By simply closing your div tags, your images will align properly. Your CSS is valid.
No one talks about FLEXBOX. Still care about old IE?
#navBar {
background-color: white;
border: 1px solid white;
border-radius: 15px;
width: 1200px;
display: flex;
justify-content: center;
align-items: center;
}
img { width: 100px; height: 100px; background: red; }
hr {
border: none;
background-color: gray;
height: 80px;
margin-left: 20px;
margin-right: 20px;
width: 3px;
}
<div id="navBar">
<img id="img1" src="img1.png" />
<hr>
<img id="img2" src="img2.png" />
<hr>
<img id="img3" src="img3.png" />
<hr>
<img id="img4" src="img4.png" />
</div>
I would recommend removing the navSplitter elements completely, as they add an extra set of items (unnecessarily) that will need to be styled to ensure the images line up. Instead, you can just add padding / borders to the images individually, which will separate them as desired. Consider the following:
.image {
display: inline-block;
height: 100%;
padding: 20px;
border-right: 3px solid gray;
}
.image:last-of-type {
border-right: none;
}
#navBar {
background-color: white;
border: 1px solid white;
border-radius: 15px;
display: inline-block;
height: 100px;
margin: auto;
margin-top: 50px;
width: 1200px;
}
<div id="navBar">
<img class="image" src="http://placehold.it/150x150" />
<img class="image" src="http://placehold.it/150x150" />
<img class="image" src="http://placehold.it/150x150" />
<img class="image" src="http://placehold.it/150x150" />
</div>

Centering div elements disregarding screen size

I have used flexbox already to try this, but for some reason it isn't working. On a smaller screen size, everything's centered. I tried doing justify-content: center for flexbox, but that isn't working. I will put down the code snippet as well as screen shots showing what I'm seeing. You may look at snippet, but it uses a combination of percents and pixels, so it may look weird. Can I handle simple centering without media queries? Even if I did use one, I still can't get it to center on my desktop.
html {
height: 100%;
}
body{
height: 100%;
margin: 0;
font-family: courier;
font-size: 19px;
}
#container {
min-height: 100%;
margin-bottom: -150px;
width: 100%;
}
#container:after {
content: "";
display: block;
}
#content{
display:flex;
float:left;
width: 800px;
flex-wrap: wrap;
justify-content: center;
}
#footer, #container:after{
height: 150px;
}
#footer{
background-color: #006699;
clear: both;
}
.wrap {
margin: 0 auto;
width: 100%;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sub {
padding: 12px;
width: 32%;
height: 120px;
color: white;
border-right: solid white 1px;
}
.sub:last-child{
border: 0px;
}
#leftbar{
width: 10%;
height: calc(100vh - 150px);
background-color: black;
float:left;
}
#rightbar{
width: 10%;
height: calc(100vh - 150px);
background-color: black;
float: right;
}
#nav {
list-style: none;
font-weight: bold;
width: 100%;
text-align: center;
background: rgba(0, 102, 153, 0.4);
height: 100px;
}
#nav ul {
list-style-type: none;
margin: 0px;
padding: 0;
overflow: auto;
// background-color: #006699;
text-align: center;
}
#nav li {
margin: 0px;
display: inline-block;
}
#nav li a {
padding: 10px;
display: inline-block;
text-decoration: none;
font-weight: bold;
font-size: 30px;
color: white;
// background-color: #006699;
}
#nav li a:hover {
color: white;
text-shadow: 2px 2px 4px white;
}
.clear {
clear: both;
}
div.img {
margin: 5px;
border: 1px solid #595959;
float: left;
width: 180px;
}
div.img:hover{
border: 1px solid #b3b3ff;
}
div.img img {
width: 100%;
height: auto;
}
div.desc{
padding: 15px;
text-align: center;
}
div.head{
text-align:center;
background-color:black;
color: orange;
}
<!DOCTYPE HTML>
<html>
<head lang="en">
<link rel="stylesheet" type="text/css" href="new.css" />
<meta charset="UTF-8">
<title></title>
<style>
</style>
<script>
</script>
</head>
<body>
<div id="container">
<div id="nav">
<ul>
<li>Home</li>
<li>Works</li>
<li>About</li>
</ul>
</div>
<div class="clear"></div>
<div class="upperbox">
<div id="leftbar"> </div>
<div id="rightbar"></div>
<div id="content">
<div class="img">
<div class="head">Color Palettes</div>
<img src="purple.png" alt="the color purple">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="blue.png" alt="the color blue">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="yellow.png" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="brown.jpg" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="grey.jpg" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="green.png" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="red.png" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="gold.jpg" alt="the color yellow">
<div class="desc">Color</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub">Lorem Ipsum</div>
<div class="sub">Lorem Ipsum </div>
<div class="sub">Lorem Ipsum </div>
</div>
</div>
</body>
</html>
erase float:left; from #content and add margin: 0 auto to it.
You can either give your #content the CSS of margin: 0 auto;, like so:
#content {
margin: 0 auto;
}
(Maybe you will also have to not float it to the left)
Or you could take a look at other modern possibilities for centering an element:
https://css-tricks.com/centering-percentage-widthheight-elements/
https://css-tricks.com/centering-in-the-unknown/
https://codemyviews.com/blog/how-to-center-anything-with-css