I want to make a control panel for the admin part of my website. The control panel I developed consists of several buttons. What I need is whenever I click one of the buttons, that option's sub-menu will appear right next to it. For example, I have "My Account" as one of the main options. If I click on the "My Account" button, its sub-menu (with Update Profile and Change Password etc.) will appear.
Here's the code for the control panel:
<div class="main-area">
<div class="control-panel">
<h1>Admin Control Panel</h1>
<button class="categories">My Account ►</button><br /><br />
<button class="categories">System Users ►</button><br /><br />
<button class="categories">Applicants ►</button><br /><br />
<button class="categories">Blacklist ►</button>
<br /><br />
<button class="categories">Jobs ►</button><br /><br />
<button class="categories">Requirements ►</button><br />
<br />
<button class="categories">Reports ►</button>
Here's the CSS part:
body {
font-family: arial;
background-color: #0F8DC7;
}
.control-panel {
border: solid 1px #000;
padding: 15px;
border-radius: 15px;
box-shadow: 5px 5px 5px;
width: 300px;
text-align: center;
display: inline-block;
height: 370px;
background-color: #FFE400;
}
.main-area {
width: 500px;
margin: auto;
}
.categories{
width: 200px;
}
Hoping for some answers not involving JavaScript.
It's just a demo, I haven't styled your code for a better view.
You have to use css :hover to achieve this functionality. And put your button(menuItem) and submenuItems(li) inside "ul" tag like this,
<ul>
<button class="categories">My Account ►</button><br /><br />
<li>First</li>
<li>Second</li>
</ul>
Add this css code ,
.main-area ul li{
display : none;
}
.main-area ul:hover li{
display : block;
background:blue;
height:auto;
width:8em;
}
Style your submenu items as you want.
jsFiddle
Related
I have a 2 horizontal part menu bar, each with a different background color.
The top bar has a menu system that will wrap if the screen is too small.
The second bar has an image and search bar.
The top bar needs to auto-size based on how many rows of options exist.
Currently the second bar's contents show up (image/search), however the background and DIV element are under the main bar.
<div id="header_nav_buttons" style="position:absolute">
<ul>
<li><asp:HyperLink ID="link1" runat="server"/></li>
<li><asp:HyperLink ID="link2" runat="server"/></li>
</ul>
</div>
<div id="sub_header">
<div id="logo">
<asp:Image runat="server" ID="img_Logo" ImageAlign="Left" Width="173px" />
</div>
<div id="search_bar">
<input name="search_input" runat="server" type="text" id="search_input" style="margin-right: 20px;" maxlength="50" />
<asp:Button ID="btn_Search" runat="server" Text="Search" CssClass="form_save_button" OnClick="search_go_Click" />
<br />
<asp:Label ID="lbl_Search_Box_Subtext" runat="server" />
</div>
</div>
CSS:
#header_nav_buttons
{
font-family: Verdana, Arial, Helvetica, sans-serif;
color: white;
float: left;
width: 100%;
background-color:#6690BF;
height: auto;
font-size: 1.5em;
line-height: 30px;
bottom: auto;
}
#header_nav_buttons ul
{
display: inline;
list-style: none;
margin: 0px;
}
#header_nav_buttons li
{
display: inline-flex;
padding-right: 13px;
}
#sub_header
{
height: auto;
width: 100%;
background-color: #e5ecf4;
}
#logo
{
width:173px;
padding-top: 15px;
}
#search_bar
{
right:20px;
margin-top: 25px;
float: right;
}
To add to the confusion, in #search_bar, if I remove float:right then some of the background shows up (while still starting too high, under the main header bar color).
I was able to solve this through some random attempts.
I added float:left to the #sub_header CSS section, and it solved the issue,
I'm doing a little HTML project, I Have a Main CSS code the HTML that I'm stuck on,
I have (as you'll see in my code) a dropdown button which gives you several options, Now what I want is for when you click one of the options-
1. It shows the option in the main dropdown button (The text on it [Changing from "$4-$30 Aud" to whatever they pick])
and I want somehow for the "Add to cart" button to change to code that would redirect to what has been picked above it (the options mention above)
Anyway thanks for you help
CSS:
.button {
background-color: #ffffff;
border: none;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 1px 2px;
cursor: pointer;
}
ul {display: inline;
list-style-type:none;
text-decoration: none;}
.button:hover{
background-color: #595959;
}
.header {
text-align: center;
background-color: #2ac9b7;
color: black;
position: fixed;
width: 100%;
padding: 20px;
}
html, body{
width:100%;
height:100%; background-color: #62666d; margin: 0px;
}
h1 {
font-weight:bold;
color: #000000;
font-size:42px;
}
.main {
font-family: arial;
margin: 0px;
}
.Content {
top:0;
bottom:0
left:0;
right:0;
margin-top: 160px
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
img
{
display: block;
margin: 0 auto;
}
HTML
<html>
<head>
<link rel="stylesheet" href="Masters_baby.css">
<div class="Main">
<div class="header">
<div class="links">
<ul><button class="button">Home</button> </ul>
<ul><button class="button">Shop</button></ul>
<ul><button class="button">Art</button></ul>
<ul><button class="button">About Me</button></ul>
<ul><button class="button">Support</button> </ul>
<ul><button class="button">Production</button></ul>
</div>
</div>
</div>
</div>
<IMG STYLE="position:absolute; TOP:23px; LEFT:20px; WIDTH:130px; HEIGHT:50px" SRC="Logo.png">
</head>
<body>
<IMG STYLE="TOP:180px; LEFT:30px; WIDTH:50px; HEIGHT:50px" SRC="Flame.png">
</body>
</div>
</div>
<div class="parallax"></div>
<div style="height:4950px; width:80%; margin:0 auto; background-color:#98eacc; margin-top: 44px">
<div class="Products" style="padding-top: 50px;">
<div class="∞ Frosted Kumquat" style= "width: 100%; height:9.1%; width:80%; margin:0 auto; background-color:#fff; ">
<p style="font-size: 25px">∞ Frosted Kumquat</p>
<IMG STYLE="WIDTH:35%; HEIGHT:63%" SRC="candle.jpg" >
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 80%;">A fresh citrusy smell that fills the room, Its is fairly stong washing out any unwanted smells or just lifting the room. Best for someone who doesnt like the smell of overly sweet but likes the fresh smell of fruit.</td>
<td>
<div class="dropdown"><button class="dropbtn">$4-$30 AUD</button>
<div class="dropdown-content">Melts $4.00 Tea light(6) $5.00 Candle in a Tin $14.00 Specitally Candles $15.00-$30.00 Boxed candle $22.00 Triplet pack of candles $28.00</div>
</div>
</td>
</tr>
<tr>
<td></td>
<td>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="kin#kinskards.com">
<!-- Specify a PayPal Shopping Cart Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Birthday - Cake and Candle">
<input type="hidden" name="amount" value="3.95">
<input type="hidden" name="currency_code" value="USD">
<!-- Display the payment button. -->
<input type="image" name="submit"
src="Add2Cart.png"
alt="Add to Cart" STYLE="WIDTH:70%; HEIGHT:20%">
<img alt="" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</html>
Again Thanks for any help :)
First of all, place all of your content in the <body>. Your head is where you link to stylesheets, load scripts and set meta-data etc. you don't want to have any content such as your header in the head.
You can achieve things like this with JavaScript. Let me give you an example.
Lets say we have the following HTML:
<select class="selector">
<option value="10">10$</option>
<option value="20" selected>20$</option>
<option value="30">30$</option>
</select>
Selected plan: <span class="selected_plan">20$</span>
We want to change the content of the span with class selected_plan to the value selected in our select element.
First we need to create a new script (load your scripts at the bottom of your body).
<script> // place your script here </script>
or
<script src="link_to_your_js_file.js"></script>
Next we need to select our elements like so:
let selector = document.querySelector('.selector');
let selectedPlan = document.querySelector('.selected_plan');
Then we listen for when the select changes:
selector.addEventListener('change', function() {
selectedPlan.innerHTML = selector.value + '$';
});
I created this JSFiddle for you so you can experiment with this particular example: https://jsfiddle.net/dgyyyoh8/1/
EDIT:
If I'm correct you want to change attributes as well. You can use the setAttribute method for this.
let link = document.querySelector('.element');
link.setAttribute('href', selected.value);
Take a look at this JSFiddle: https://jsfiddle.net/dgyyyoh8/2/
Select our element
Create an event for when the selector changes
Set the innerHTMl of the link equal to 'Go to (text of the option)'
Set the href attribute equal to the selected options' value.
EDIT:
There are ways to change the appearance of the select element.
For example: https://codepen.io/ericrasch/pen/zjDBx
I'd suggest you also take a look at the CSS Framework Bootstrap. This framework contains a lot of classes you can work with to really take your styling to the next level.
I recently edited the way a template was designed for MyBB. Fortunately, I made it exactly how I expected it to look, however, the navigation bar seemed broke. After trying to navigate, I realized that I could only click on the lower half of the navigation.
http://gyazo.com/99337bd5252b37e118ce119d5168bcf3
As you can see where I painted the red boxes is the only place where the link activation works. After about 2 hours I found out my problem was due to a "position: relative;". When I remove it, the navigation works fine but my panel div becomes moved all the way to the right and out of position.
<div class="main-bg">
<div class="main-width">
<a name="top" id="top"></a>
<div class="top-bar blue-texture"></div>
<div id="header">
<div id="panel">
{$welcomeblock}
</div>
<div class="logo" >
<img src="{$theme['logo']}" alt="{$mybb- >settings['bbname']}" title="{$mybb->settings['bbname']}" />
</div>
<hr class="hidden" />
</div>
</div>
</div>
<div id="container">
<div class="bg-img">
</div>
<hr class="hidden" />
<div class="menu blue-texture">
<span class="search">
<form action="search.php" method="post">
<input type="hidden" name="action" value="do_search" />
<input type="hidden" name="postthread" value="1" />
<input type="hidden" name="forums" value="all" />
<input type="hidden" name="showresults" value="threads" />
<input type="text" name="keywords" value="search..." onfocus="if(this.value == 'search...') { this.value = ''; }" onblur="if(this.value=='') { this.value='search...'; }" size="22" />
<input type="submit" value="Go" class="search-button" title="Search the forums" />
</form>
</span>
<ul>
<li>Home</li>
<li>Tournaments</li>
</ul>
</div>
There is the complete code on how I have developed this. However, the problem is mainly in the CSS.
#header {
padding: 60px 0 85px;
height: 56px;
text-align: left;
position: relative;
}
#panel {
background: rgba(0,0,0,0.4);
color: #fff;
border: 1px solid #07090b;
border-radius: 6px;
position: absolute;
top:0;
margin-top: 0px;
right: 0;
padding-top: 4px;
font-size: 12px;
padding-right: 12px;
padding-left: 12px;
height: 130px;
}
.menu {
border-radius: 6px;
-webkit-border-radius: 6px;
border: 1px solid #174d7b!important;
height: 50px;
}
I can't find a way to fix the problem however, because there is no way to add position:relative; and make the navigation links still work as they are intended to.
Without actual link or a working snippet it would be hard to find the issue, but please try this css that may solve your problem:
.menu { width: 100%; }
.menu ul li a { display: inline-block; width: auto; float: left; }
Hope this helps
I'm brushing up my HTML/CSS skills for a new job. The last time I wrote some HTML was in 1999... So, no need to say that I fell behind.
So, as a fan of "Space Trader" game on Palm OS, I have decided to rewrite in HTML all the screens of the game. And I'm struggling with a CSS issue.
Here is the screen I'm trying to rewrite :
And here is my markup :
<div class="screenTitle">
<h1 class="leftTitle">Bank</h1>
<span class="titleButtons">
<input type="button" id="btB" value="B" />
<input type="button" id="btS" value="S" />
<input type="button" id="btY" value="Y" />
<input type="button" id="btW" value="W" />
</span>
</div>
And the CSS :
.screenTitle {
height: 0.7em;
border-bottom-style: solid;
border-color: rgb(49,0,156);
font-size: 40px;
}
.leftTitle {
margin-top: 0;
font-size: 0.5em;
text-align: center;
color: white;
padding-left: 0.1em;
padding-right: 0.1em;
background-color: rgb(49,0,156);
float: left;
border-top-left-radius: 0.3em;
border-top-right-radius: 0.3em;
line-height: 1.5em;
font-weight: bold;
}
.titleButtons {
float: right;
}
And here is the result
So, you can see that I'm struggling with the positionning of the 4 shortcuts buttons.
Do you have any clue for me to sort this out ? And do you have any critic to formulate ?
Thanks a lot
You need to change the vertical alignment of your buttons. Have this in your CSS:
.titleButtons input{
vertical-align:top;
}
Demo
.titleButtons input {
float: right;
vertical-align:top;
margin:7px 0px 0px 0px;
}
If you add some top margin and remove som left/right margins, the buttons will also position themselves nicer on the bar.
Let me start out by saying I am no fan of tables but I have not been able to come up with an elegant solution to this issue.
I am trying to setup a page that has a search bar with three buttons to the left followed by two hyperlinks stacked on top of one another. This entire control needs to be rendered in the center of the webpage
Where I ran into the first issue was with the hyperlinks the only way I seemed to get this layout was using a table.
This leads to the second issue of it not properly rendering in safari or chrome. IE and firefox renders this in the center of the page as desired with everything in the proper position. However Safari and chrome take the table (containing the hyperlinks) and slam it to the immediate left of the page.
Can anyone point me in the correct direction as to how to render out these elements to obtain the desired layout or at least correct the issue I am having in Safari/chrome of the table rendering to the left of everything else.
Code below
html
<div id="search" class="searchcontainer">
<asp:TextBox ID="tbsearchterm" CssClass="watermark" runat="server" OnTextChanged="tbsearchterm_TextChanged" />
<div class="buttons">
<asp:LinkButton runat="server" Text="Search" class="button search-big" ID="btnSearch"
OnClick="btnSearch_Click" />
<asp:LinkButton runat="server" Text="Fx" class="button left big" ID="btnOperators" />
<asp:LinkButton runat="server" Text="Save" class="button right big" ID="btnSave" />
</div>
<table id="searchoptions">
<tr>
<td>
Advanced Search
</td>
</tr>
<tr>
<td>
Filters
</td>
</tr>
</table>
</div>
CSS
.searchcontainer
{
min-width:840px;
display:inline;
position:relative;
padding-top:20px;
margin-left:auto;
margin-right:auto;
}
#searchoptions
{
display:inline;
text-align:left;
font-size:.8em;
width:100px;
padding:0px;
vertical-align:top;
position:relative;
margin:0px;
}
#tbsearchterm {
width:470px;
height:32px;
text-align:left;
padding-left:10px;
padding-right:10px;
font-size: 1.3em;
border:1px solid #cccccc;
-khtml-border-radius: 2px;
-ms-border-radius: 2px;
-o-border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
Thanks in advance for any tips or suggestions
Update
This control also uses jquery to hide certain elements when the page loads. As a result float is not the best option. When some of the elements are hidden the control still renders off to the left. For this reason I need to use display:inline for the elements nested in the main container ("searchcontainer").
body { width: 100%; text-align: center; }
.container { overflow: hidden; width: 500px; margin: 0 auto; }
input { float: left; }
button { float: left; }
.links { float: left; }
<div class="container">
<input type="text"/>
<button id="button1">Button 1</button>
<button id="button2">Button 2</button>
<button id="button3">Button 3</button>
<div class="links">
Link 1<br/>
Link 2<br/>
</div>
</div>
Just float the inputs, buttons and .link div left. Should work in all browsers. :)
Check it out here: http://jsfiddle.net/F7hQf/