I am designing a website, and have these menu buttons which will act as like a banner near the top of the page for navigation.
However, at the moment on the website the buttons are in a vertical line. How do i make them horizontal?
here is the button:
button1 {
display: block;
width: 175px;
box-sizing: border-box;
margin: 0.5rem auto;
padding: 0.75rem;
font-size: 1.5rem;
text-align: center;
color: white;
border: solid #ffffff 2px;
background: #8ec8ea;
border-radius: 0.5rem;
outline: none;
cursor: pointer;
}
and my html where ive made the buttons..
<t><button1>Home</button1></t>
<t><button1>Facilities</button1></t>
<t><button1>Facilities</button1></t>
<t><button1>Donate</button1></t>
<t><button1>News</button1></t>
<t><button1>Testimonials</button1></t>
<t><button1>Contact us</button1></t>
Also, if there is better practice of doing this - let me know!
Just change your display: block; to display: inline-block; in your button1 css
JSFiddle: http://jsfiddle.net/ghorg12110/8wzgddhg/1/
And if you want a HTML W3C valid :
HTML:
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/" class="button1">
Home
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Facilities.html" class="button1">
Facilities
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Facilities.html" class="button1">
Facilities
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Donate.html" class="button1">
Donate
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/News.html" class="button1">
News
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Testimonials.html" class="button1">
Testimonials
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Contact.html" class="button1">
Contact us
</a>
</div>
CSS:
.button1 {
width: 175px;
box-sizing: border-box;
margin: 0.5rem auto;
padding: 0.75rem;
font-size: 1.5rem;
text-align: center;
color: white;
border: solid #ffffff 2px;
background: #8ec8ea;
border-radius: 0.5rem;
outline: none;
cursor: pointer;
display: inline-block;
text-decoration: none;
}
.t {
display: inline-block;
}
JSFiddle : http://jsfiddle.net/ghorg12110/8wzgddhg/2/
Related
I don't know how to describe this problem. I'm using three styling frameworks Bootstrap, Semantic, and Materialize CSS. I've created an unordered list after that there is a button when I use the br tag to separate them separation works but the gap doesn't fill with the body background color so I used margin but still, the gap is not filling with body color.
You can see this problem in this
HTML code
<section>
<div class="container dashboard ">
<div class="row">
<aside class="col-sm-3">
<ul class="list-group text-center">
<a class="list-group-item active" href="#">Dashboard</a>
<a class="list-group-item" href="#">All Posts</a>
<a class="list-group-item" href="#">Create/Edit Posts</a>
</ul>
<a class="btn btn-light btn-block" href="#"> <i class="fa fa-power-off"></i> <span class="text">Log out</span> </a>
</aside>
</div>
</div>
</section>
CSS
.dashboard{
margin-top: 100px;
margin-bottom: 100px;
padding: 30px 0px;
}
.dashboard .col-sm-3{
border-bottom: none;
border-radius: 5px;
height: fit-content;
padding-left: 0;
padding-right: 0;
background: #fff;
}
.dashboard .col-sm-3 ul a{
text-decoration: none;
font-weight: 500;
}
.dashboard .col-sm-3 .btn {
margin-top: 50px;
}
.btn-light {
background-color: #fff;
border-color: #e4e4e4;
text-align: center;
}
.btn-light span{
text-transform: none;
font-weight: 500;
}
You can check this question this thing will help you link
Actually, this question helps me too I've also faced a similar situation.
I will make this more simple I think this work you can try this
br {
content: "A" !important;
background: #fafafa !important;
display: block !important;
width: 100% !important;
height: 30px !important;
}
I would like to know if someone could help me with a CSS topic.
I am creating a page model through CSS, but it turns out that there is a part that does not stay the same as the rest.
It appears as follows:
enter image description here
And it should look like this, like the footer in the following image.
Do you suggest any ideas? I leave here the code that I have used for CSS.
enter image description here
I attach the HTML and CSS code used.
I tried to move the height and width but can't find the solution.
<!--Inicio de pie de página-->
<div class="clearfix"></div>
<footer id="footer">
<div class="wrap">
<div id="menu_footer">
<h5>Menú</h5>
<ul>
<li>Inicio</li>
<li>Blog Personal</li>
<li>Currículum</li>
<li>Contacto</li>
</ul>
</div>
<div id="location">
<h5>¿Dónde estamos?</h5>
<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3037.4968410733713!2d-3.690925684351!3d40.41999606336424!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd42289a4a865227%3A0x98278b3a144a86f1!2sPuerta%20de%20Alcal%C3%A1!5e0!3m2!1ses!2ses!4v1599489227264!5m2!1ses!2ses"
width="600" height="450" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false"
tabindex="0">
</iframe>
<div id="info">
<h5> Desarrollado con</h5>
<p>
<img src="img/html5-badge-h-css3-graphics-multimedia-performance-semantics.png"
alt="Creado con HTML y CSS">
</p>
<h5>Optimizado para</h5>
<p id="browsers">
<a href="#">
<img src="img/firefox-icon.png" alt="Firefox" title="Firefox">
</a>
<a href="#">
<img src="img/chrome.png" alt="chrome" title="Chrome">
</a>
<a href="#">
<img src="img/Opera_256x256.png" alt="Opera" title="Opera">
</a>
<a href="#">
<img src="img/safari.png" alt="Safari" title="Safari">
</a>
<a href="#">
<img src="img/android.png" alt="Android" title="Android">
</a>
<a href="#">
<img src="img/ios.png" alt="Apple" title="Apple">
</a>
</p>
<h5>Autor</h5>
<p>©Cristina Martínez - acmartinez96.blogspot.com</p>
</div>
</div>
</div>
</footer>
<!--Fin de pie de página-->
</body>
</html>
/FOOTER/
#footer h5
display: block;
background: url(../img/pxgray.png), white;
height: 55px;
letter-spacing: 2px;
text-align: center;
font-family: "BebasNeue";
font-size: 40px;
line-height: 55px;
color: black;
border-radius: 5px;
margin-bottom: 15px;
#footer ul
text-align: left;
margin: 20px;
font-size: 25px;
#footer ul li
margin-top: 10px;
padding: 5px;
border-bottom: 1px solid #cccccc;
#footer ul li a
display: block;
height: 40px;
#footer iframe
width: 100%;
height: 300px;
margin-top: 10px;
border-radius: 5px;
box-shadow: 0x 0px 5px grey;
border: 5px solid white;
}
#footer img
margin-bottom: 15px;
#footer #browsers img{
width: 45px;
Thanks!
Try to use flexbox it's very helpful.
the rendering you request can be done simply this way
<div class="flex">
<div class="ll">Menu</div>
<div class="ll">Map</div>
<div class="ll">Footer</div>
</div>
div.ll {
background: #fff;
margin: 20 auto;
width: 200px;
padding: 50px;
text-align: center;
}
div.flex {
display: flex;
}
You can test it by using sandbox
Instead of a footer, try creating a <div> or <section> and align that to the right.
This question already has answers here:
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
Closed 2 years ago.
once again I have a problem with centering elements. I have this HTML/CSS:
<section class="btmfix">
<div class="menurow">
<div class="col">
<a class="sml-btn" href="index.html">HOME</a>
</div>
<div class="col">
<a class="sml-btn" href="about.html">ABOUT</a>
</div>
<div class="col">
<a class="sml-btn" href="product.html">PRODUCT</a>
</div>
<div class="col">
<a class="sml-btn" href="request.php">REQUEST</a>
</div>
<div class="col">
<a class="sml-btn" href="contact.html">CONTACT</a>
</div>
</div>
</section>
.menurow {
height: auto;
display: inline-block;
margin: 0 auto;
width: auto;
}
.btmfix {
display: block;
padding-bottom: 0px;
}
.col {
padding: 0px;
display: block;
}
.sml-btn {
color: #000;
text-decoration:none;
background-color:#444;
margin: 3px;
width: 180px !important;
/* width:auto !important;*/
padding: .3rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
border-radius: .3rem;
display: inline-block;
/* font-weight: 00;*/
text-align: center;
vertical-align: middle;
border: 1px solid #fff;
cursor: pointer;
text-transform: uppercase;
text-shadow: 1px 0px #fff;
}
https://jsfiddle.net/crapomat/pLt5j0sy/5/
I want the links to be centered, but I cant figure out how. I tried the margin: 0 auto; method, this is found in almost every tutorial, but it doesn't work here. Do you know why? Can you help me?
Thx in advance
To center menu horizontally you need to apply text-align: center; on .col class.
Here is the working example:
.menurow {}
.btmfix {
display: block;
padding-bottom: 0px;
}
.col {
padding: 0px;
text-align: center;
}
.sml-btn {
color: #000;
text-decoration:none;
background-color:#444;
margin: 3px;
width: 180px !important;
padding: .3rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
border-radius: .3rem;
display: inline-block;
text-align: center;
vertical-align: middle;
border: 1px solid #fff;
cursor: pointer;
text-transform: uppercase;
text-shadow: 1px 0px #fff;
}
<section class="btmfix">
<div class="menurow">
<div class="col">
<a class="sml-btn" href="index.html">HOME</a>
</div>
<div class="col">
<a class="sml-btn" href="about.html">ABOUT</a>
</div>
<div class="col">
<a class="sml-btn" href="product.html">PRODUCT</a>
</div>
<div class="col">
<a class="sml-btn" href="request.php">REQUEST</a>
</div>
<div class="col">
<a class="sml-btn" href="contact.html">CONTACT</a>
</div>
</div>
</section>
you are given width:0; to menurow that is the issue and add col to text-align:center
.menurow {
width: 100%;
}
.col {
text-align: center;
}
If you want to take all menu group to center text-align:center; is enough
.btmfix {
display: block;
padding-bottom: 0px;
width: 100%;
text-align:center;
}
If you also want to show menu horizantally then float:left; is enough
.col {
padding: 0px;
display: block;
float:left;
}
Right now I have dropdown menus in a vertical direction like this:
I want to change the dropdown menu so that they appear in a horizontal direction, preferred centered of a menu item:
I am using divs (.dropdown, .dropdown-content)
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.dropdown-content {
display: none;
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
width: 150px;
height: auto;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
padding-bottom: 10px;
}
How can I change the direction and alignment?
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
<hr class="horizontal">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
<hr class="horizontal">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
</div>
</div>
You can use FlexBox to achieve the wanted result. Keep in mind, that flexbox is farily new and not supported in older browsers.
What I did:
Change the display-setting of dropdown-content to display:flex; and added flex-direction: row to align them horizontally.
Then I wrapped all dropdown-elements with a div to give every element of the dropdown some styling in case of need.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-radius: 5px;
}
.dropdown-content {
/*display: none; //Change this to display flex, with the flex-direction to align the items horizontally*/
display: flex;
flex-direction: row;
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
height: auto;
border-radius: 5px;
padding-bottom: 10px;
}
.dropdown-content-element{
margin: 2px 5px;
padding: 5px;
}
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="dropdown-content-element">
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
<div class="dropdown-content-element">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
<div class="dropdown-content-element">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
</div>
</div>
And here is a little cheatsheet to get you started with FlexBox.
EDIT:
This works, but without being centered on the selected supermenu-item. But you'll achieve that yourself, I trust in you!
Oh and by the way: You can sum up your border-radius rules with border-radius: 5px; if all are the same. Saves some space and maintains better readability.
EDIT 2:
Here is an example of using ul and li to achieve a similar result. This method was suggested by #Moose in one of his comments.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-radius: 5px;
}
.dropdown-content {
/*display: none;*/
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
height: auto;
border-radius: 5px;
padding-bottom: 10px;
}
.dropdown-list {
list-style: none;
}
.dropdown-list>li {
display: inline-block;
}
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<ul class="dropdown-list">
<li>
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
<li>
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
<li>
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
</ul>
</div>
</div>
I'm creating a sort draft 'Contact Us' page and I thought I'd play around with the hover property in CSS. See my code below.
.hoverinfo {
position: static;
color: #000000;
cursor: pointer;
}
.hoverinfo p {
display: none;
color: #000000;
border: 4px;
}
.hoverinfo:hover p {
background-color: #C4C4C4;
margin: 20px;
border: 1px solid black;
display: inline-block;
}
<p>Test</p>
<div id="contact" class="info">
<ul>
<li>
<div id="phone" class="hoverinfo">Telephone
<p>Number</p>
</div>
</li>
<li>
<div id="twitter" class="hoverinfo">Twitter
<p>Twitter URL</p>
</div>
</li>
</ul>
</div>
My issue at the moment is when I hover over 'Telephone' or 'Twitter', the actual text itself moves. I had a look around and people are usually saying it's because of padding, but I don't have any! This only started because I wanted to move the actual text that pops up farther to the right hand side because it was way too close to the other text when it popped up.
You can use the following solution using display:inline; on the visible / hovered <p> item:
.hoverinfo {
position: static;
color: #000000;
cursor: pointer;
}
.hoverinfo p {
display: none;
color: #000000;
}
.hoverinfo:hover p {
background-color: #C4C4C4;
border: 1px solid black;
margin:20px;
display: inline;
}
<p>Test</p>
<div id="contact" class="info">
<ul>
<li>
<div id="phone" class="hoverinfo">Telephone
<p>Number</p>
</div>
</li>
<li>
<div id="twitter" class="hoverinfo">Twitter
<p>Twitter URL</p>
</div>
</li>
</ul>
</div>
You need to just add position absolute to p Tag on hover.
.hoverinfo {
position: static;
color: #000000;
cursor: pointer;
}
.hoverinfo p {
display: none;
color: #000000;
border: 4px;
}
.hoverinfo:hover p {
background-color: #C4C4C4;
border: 1px solid black;
display: inline-block;
position: absolute;
margin-top: 0px;
}
<p>Test</p>
<div id="contact" class="info">
<ul>
<li>
<div id="phone" class="hoverinfo">Telephone
<p>Number</p>
</div>
</li>
<li>
<div id="twitter" class="hoverinfo">Twitter
<p>Twitter URL</p>
</div>
</li>
</ul>
</div>