grouped vm output to a view - asp.net-mvc-3

I'm looking for the best/simplest way to output the following using Razor (ASP.Net MVC 4)
<ul id="contacts">
<li data-group="a">
<a class="title">A</a>
<ul>
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="~/backendContent/sample/p4.jpg"></span> Adam Woodward
<span style="font-size: 11px; display: block;" class="muted">Creative Director</span>
</a>
</li>
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="~/backendContent/sample/p5.jpg"></span> Aileen Espinoza
<span style="font-size: 11px; display: block;" class="muted">Creative Director</span>
</a>
</li>
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="~/backendContent/sample/p6.jpg"></span> Aimee Foley
<span style="font-size: 11px; display: block;" class="muted">Creative Director</span>
</a>
</li>
</ul>
</li>
<li data-group="b">
<a class="title">B</a>
<ul>
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="~/backendContent/sample/p1.jpg"></span> Baker Terry
<span style="font-size: 11px; display: block;" class="muted">Creative Director</span>
</a>
</li>
</ul>
</li>
<li data-group="c">
<a class="title">C</a>
<ul>
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="~/backendContent/sample/p1.jpg"></span> Cadman Mosley
<span style="font-size: 11px; display: block;" class="muted">Creative Director</span>
</a>
</li>
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="~/backendContent/sample/p2.jpg"></span> Cailin Jones
<span style="font-size: 11px; display: block;" class="muted">Creative Director</span>
</a>
</li>
</ul>
</li>
.
.
.
as you can see its a contact list that will be formatted to a nice phonebook. I currently have a iqueryable that holds all the information in alphabetical order. I honestly was not sure on how to use razor to structure the above html. I thought about using a group function in linq and came up with the following linq expression:
var _customers = (from c in _db.UserProfiles.Include("ParentCompanies").Include("cProfile")
where (c.ParentCompanies.Any(pc => pc.CompanyUsers.Any(cu => cu.UserName == userName)) && c.cProfile != null)
group c by c.FirstName.Substring(0, 1) into customerGroup
select new { FirstLetter = customerGroup.Key, Information = customerGroup }).OrderBy(letter=>letter.FirstLetter);
but I came across some problems with the return type of the method (anonymous type) and I was not sure how to deal with that. I am now using the following:
var _customers = (from c in _db.UserProfiles.Include("ParentCompanies").Include("cProfile")
where (c.ParentCompanies.Any(pc => pc.CompanyUsers.Any(cu => cu.UserName == userName)) && c.cProfile != null)
select c).OrderBy(f=>f.FirstName);
I am very new to the asp.net MVC world and any help would be greatly appreciated.

You can declare a custom return type for your query and use that as your view model.
public class GroupedCustomersViewModel
{
string FirstLetter { get; set; }
IEnumerable<UserProfile> Information { get; set; }
}
....
var _customers =
(from c in _db.UserProfiles.Include("ParentCompanies").Include("cProfile")
where (c.ParentCompanies.Any(pc => pc.CompanyUsers.Any(cu => cu.UserName == userName)) && c.cProfile != null)
group c by c.FirstName.Substring(0, 1).ToUpper() into customerGroup
select new GroupedCustomersViewModel
{
FirstLetter = customerGroup.Key,
Information = customerGroup
})
.OrderBy(letter=>letter.FirstLetter);
In your .cshtml use
#model IEnumerable<MyProject.Namespace.Models.GroupedCustomersViewModel>
...
<ul id="contacts">
#foreach(var group in Model)
{
<li data-group="#group.FirstLetter.ToLower()">
<a class="title">#group.FirstLetter</a>
<ul>
#foreach(var user in group.Information)
{
<li>
<a href="#">
<span class="thumbnail">
<img alt="" src="#user.Thumbnail"></span> #user.Name
<span style="font-size: 11px; display: block;" class="muted">#user.Title</span>
</a>
</li>
}
</ul>
</li>
}
</ul>

Related

How to make a navbar responsive bootstrap

Hello i am trying to make a navbar in laravel with bootstrap, i am not that good in front-end so i am learning. The navbar in bigger screen shows good but in smaller one the buttons are more to the right side of the screen. This is the code that i have done:
Html:
<div>
<nav id="sidebar" class="active">
<div class="text-start">
<div class="sidebar-header">
<img src="{{ asset('assets/img/cash-flow.png') }}" class="image" alt="logo" class="app-logo">
</div>
<div class="horizontal-menu">
<div class="row">
<div class="col-sm-1">
<div class="dropdown">
<button class="dropDownButton"><i class="fas fa-home"></i> Dashboard</button>
</div>
</div>
<div class="col-sm-1">
<div class="dropdown">
<button class="dropDownButton">
<i class="fas fa-list"></i>
Veprime</button>
<div class="dropdown-content">
<i class="fas fa-solid fa-plus"></i> Porosite
<i class="fas fa-money-bill-wave"></i> Konfirmo shpenzim
<i class="fas fa-receipt"></i> Konfirmo Arketim
<i class="fas fa-solid fa-user-pen"></i> Veprimet e mia
</div>
</div>
</div>
<div class="col-sm-1">
<div class="dropdown">
<button class="dropDownButton">
<i class="fas fa-solid fa-check-to-slot"></i> Arka</button>
<div class="dropdown-content">
<i class="fas fa-cash-register"></i> Arka
<i class="fas fa-coins"></i> Konvertim
<i class="fas fa-solid fa-hand-holding-dollar"></i> Monedhat
</div>
</div>
</div>
<div class="col-sm-1">
<div class="dropdown">
<button class="dropDownButton">
<i class="fas fa-solid fa-screwdriver-wrench"></i> Administrimi</button>
<div class="dropdown-content">
<i class="fas fa-user"></i> Perdoruesit
<i class="fas fa-random"></i> Rolet
</div>
</div>
</div>
<div class="col-sm-1">
<div class="dropdown">
<button class="dropDownButton"><i class="fas fa-solid fa-file-invoice"></i> Faturimi</button>
</div>
</div>
<div class="col-sm-1">
<div class="dropdown">
<button class="dropDownButton"><i class="fas fa-regular fa-share-from-square"></i> Shpenzimet e mia</button>
</div>
</div>
<div class="col-sm-1">
<div class="dropdown">
<a href="#" id="nav2" class="nav-item nav-link dropdown-toggle text-secondary" data-bs-toggle="dropdown" aria-expanded="false"> <button class="dropDownButton">
<i class="fas fa-user"></i> <span>{{ auth()->user()->name }}</span>
</button></a>
<div class="dropdown-profile">
<i class="fas fa-address-card"></i> Profili
<a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();" class="dropdown-item">
<i class="fas fa-sign-out-alt">
</i> Logout
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
#include('partials.menu-horizontal')
CSS
<script
src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="
crossorigin="anonymous"></script>
<!--Font Awesome-->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
rel="stylesheet"
/>
<!-- Google Fonts-->
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
rel="stylesheet"
/>
<!--MDB-->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/6.1.0/mdb.min.css"
rel="stylesheet"
/>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/6.1.0/mdb.min.js"
></script>
<style>
.dropDownButton {
background-color: white;
color: #6c757d;
padding: 16px;
font-size: 16px;
border: none;
width:200px;
}
.horizontal-menu{
width:850%;
top:10px;
margin-left: 210%;
}
.dropdown {
width:90px;
margin-top: -55px;
margin-left: 6%;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
width: 200%;
z-index: 1;
}
.dropdown-profile {
display: none;
position: absolute;
background-color: #f1f1f1;
width: 220%;
z-index: 1;
}
.dropdown-profile a{
color: black;
padding: 12px 16px;
text-decoration: none;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
a{
color:#6c757d;
}
.dropdown-content a:hover {background-color: #2196f3; color:white;}
.dropdown-item:hover {background-color: #2196f3; color:white;}
.dropdown:hover .dropdown-profile {display: block;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropDownButton {background-color: #2196f3; color:white;}
.image{
width:100px;
height:48px;
margin-left: 150%;
}
</style>
How it looks like in smaller screen:
How it looks in bigger screen:
As you can see the admin is off the screen i need the navbar to stay static to the changes. My css is for sure bad as i said im learning.
This is not the proper way of using navbar of bootstrap.
Check out this method in which the use of css is minimal, and mosly used boostrap class and components
.navbar-logo {
width: 140px;
}
.dropdown-menu{
background-color: #f1f1f1;
}
.dropdown-item > i ,.nav-link > i{margin-right:8px;}
.nav-link{white-space:nowrap}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<nav class="navbar navbar-expand-md fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img class="img-fluid navbar-logo" src="https://cashflow.io/wp-content/uploads/2021/03/CashflowLogo.png" />
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar" aria-labelledby="offcanvasNavbarLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Offcanvas</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-home"></i>Dashboard</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-list"></i>Veprime
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"><i class="fas fa-solid fa-plus"></i>Porosite</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-money-bill-wave"></i>Konfirmo shpenzim</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-receipt"></i>Konfirmo Arketim</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-solid fa-user-pen"></i>Veprimet e mia</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-solid fa-check-to-slot"></i>Arka
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"><i class="fas fa-cash-register"></i>Arka</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-coins"></i>Konvertim</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-solid fa-hand-holding-dollar"></i>Monedhat</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-solid fa-screwdriver-wrench"></i>Administrimi
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"><i class="fas fa-user"></i>Perdoruesit</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-random"></i>Rolet</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-solid fa-file-invoice"></i>Faturimi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-regular fa-share-from-square"></i>Shpenzimet e mia</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-user"></i>Admin
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"><i class="fas fa-address-card"></i>Profili</a></li>
<li><a class="dropdown-item" href="#"><i class="fas fa-sign-out-alt">
</i>Logout</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</nav>
I fixed my code by using this example in W3SCHOOLS. Code Example

Page content moves behind sidebar, Bootstrap

I've written a sidebar using Bootstap 5 which is placed on my _Layout view. The issue I'm having is when I load a new page like a users view, initialy it looks great, until I resize my screen and then the content on the users view slides behind the sidebar. I've tried placing the sidebar in a new column and row, etc but nothing I do seems to fix this. Below is my sidebar code, any help on this issue will be greatly appreciated.
<!-- Side Nav-->
<div class="container-fluid">
<div class="row">
<nav class="sidebar card py-2 mb-4 col-2 float-start vh-100 rounded-0 position-fixed" style="background-color: rgb(95,131,183);
width: 250px; padding-left: 0px; padding-right: 0px">
<ul class="nav flex-column" id="nav_accordion">
<li class="nav-item border-bottom">
<a class="nav-link bi bi-house" asp-area="" asp-controller="Home" style="color:whitesmoke; padding-left: 10px"> Home </a>
</li>
<li class="nav-item border-bottom">
<a class="nav-link bi bi-gear" href="#" style="color:whitesmoke; padding-left: 10px"> Settings </a>
</li>
<li class="nav-item border-bottom">
<a class="nav-link bi bi-speedometer" href="#" style="color: whitesmoke; padding-left: 10px"> Dashboard </a>
</li>
<li class="nav-item has-submenu border-bottom">
<a class="nav-link bi bi-people" href="#" style="color: whitesmoke; padding-left: 10px"> Contacts </a>
<ul class="submenu collapse" style="padding-left: 0px; padding-right: 0px">
<li><a class="nav-link" asp-area="" asp-controller="Users" asp-action="UsersIndex" style="color: whitesmoke"> Users </a></li>
<li><a class="nav-link" href="#" style=" color: whitesmoke"> Customers </a></li>
<li><a class="nav-link" href="#" style=" color: whitesmoke"> Suppliers </a></li>
</ul>
</li>
#* <li class="nav-item">
<a class="nav-link" href="#"> Something </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"> Other link </a>
</li>*#
</ul>
</nav>
</div>
</div
Many thanks
AJ

Excluding all tables with XPath and Scrapy

I have the following html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Scrapy</title>
</head>
<body>
<table style="border: #ffffff 0px solid" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center">
<div style="margin-top:7px;margin-bottom:7px;font-size:16px;font-weight:bold;font-color:white" width="100%">
Scrapy Rocks
</div>
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" style="margin-top:25px">
<tr>
<td align="left" valign="top"></td>
<td valign="top">
<font size="-1">
<div style="margin-right:10; margin-top:5; text-align: right">
AAA |
BBB |
CCC
</div>
</font>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div>
<a href="http://example.com" target="_blank">
<img src="/images/a.jpg" border="0" vspace="0" width="100" height="100" valign="middle"/>
</a>
<a href="/index.html">
<img src="/images/aaa.gif" border="0" vspace="0" width="100" height="100" valign="middle"/>
</a>
</div>
</td>
<td valign="top">
<div style="margin-right:10; margin-top:5; text-align: right"></div>
</td>
</tr>
</table>
<hr size=1>
<h2 style="margin-top: 36px; margin-bottom: 24px">
Abcd efgh for 2017
</h2>
Part 1 |
Part 2 |
Part 3 |
Part 4 |
A very bold title
<hr size="1" style="margin-top: 36px; margin-bottom: 24px">
<a name="part1"></a>
<h3>Part 1</h3>
<ul>
</ul>
<a name="part2"></a>
<h3>Part 2</h3>
<ul>
</ul>
<a name="part3"></a>
<h3>Part 3</h3>
<ul>
</ul>
<a name="part4"></a>
<h3>Part 4</h3>
<ul>
</ul>
<div style="margin-top: 36px; margin-bottom: 24px">
<a name="non_rep"></a>
<h3>Abcd efgh</h3>
</div>
<b>January 2017</b>
<ul>
<li>
<b>Part1 1</b>
</li>
<ul>
<li>
Title 1
</li>
<br>
<li>
Title 2
</li>
<br>
</ul>
<li>
<b>Part1 2</b>
</li>
<ul>
<li>
Title A
</li>
<br>
<li>
Title B
</li>
<br>
</ul>
<li>
<b>Part1 3</b>
</li>
<ul>
<li>
Some text 1
</li>
<br>
<li>
Some Text 2
</li>
</ul>
</ul>
<b>February 2017</b>
<ul>
<li>
<b>Part1 1</b>
</li>
<ul>
<li>
Title 1
</li>
<br>
<li>
Title 2
</li>
<br>
</ul>
<li>
<b>Part1 2</b>
</li>
<ul>
<li>
Title A
</li>
<br>
<li>
Title B
</li>
<br>
</ul>
<li>
<b>Part1 3</b>
</li>
<ul>
<li>
Some text 1
</li>
<br>
<li>
Some Text 2
</li>
</ul>
</ul>
<b>March 2017</b>
<ul>
<li>
<b>Part1 1</b>
</li>
<ul>
<li>
Title 1
</li>
<br>
<li>
Title 2
</li>
<br>
</ul>
<li>
<b>Part1 2</b>
</li>
<ul>
<li>
Title A
</li>
<br>
<li>
Title B
</li>
<br>
</ul>
<li>
<b>Part1 3</b>
</li>
<ul>
<li>
Some text 1
</li>
<br>
<li>
Some Text 2
</li>
</ul>
</ul>
</body>
</html>
What i need here is to extract the text between the body tags (using Scrapy xpath) but I don't want the tables text at all.
What I tried to get all the text was:
def parse(self, response):
"""
-*-
"""
item = DummyItem()
title = response.xpath('//title/text()').extract()
body = "\n ".join(
response.xpath(
'//body//*[not(self::script or self::style)]/text()'
).extract()
)
item['title'] = title
item['body'] = body
yield item
Whit the above stanza, I managed to extract all the text, tables inclusive, which I don't want.
Then I replaced the "body" with:
body = "\n ".join(
response.xpath(
'//body//*[not(self::table or self::script or self::style)]/text()'
).extract()
)
It didn't do the job. Still extracting the tables text.
Any ideas on how to tackle it?
You want "all text nodes that are not in a <table>", or "all text nodes that do not have a <table> ancestor".
That's /html/body//text()[not(ancestor::table)] in XPath.
text_nodes = response.xpath("/html/body//text()[not(ancestor::table)]").extract()
now you only need to strip whitespace from the resulting items and remove empty strings from the list.
body = "\n ".join(filter(None, map(str.strip, text_nodes)))

How to create nested dropdown in drodown item of navbar menu with bootstrap 3?

friends!
Is there any opportunity to create nested dropdown(multilevel dropdown) inside of dropdown menu item with bootsrap 3? Here is http://jsfiddle.net/kkqxgfk6/1/ what i'm trying to do. May be I made mistake somewhere in the code, is that so?
Here is the html-code:
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li class="dropdown">
Dropdown2 <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li ><a href="#" >Something</a>
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li>Separated link
</li>
</ul>
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li>Separated link
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
The nested "Dropdown2" menu item cann't be opened like its parent menu item called "Dropdown"
Add all bold content into your code.
<ul class="dropdown-menu" role="menu" **onclick="event.stopPropagation();"**>
<li class="dropdown" **id="test"**>
Dropdown2 <span class="caret"></span>
Add this code into javascript.
$( "#test1" ).click(function() {
$(this).attr("aria-expanded", "true");
$('#test').addClass("open");
});
Reasons for your problem By default when you click inside dropdown it closes.
here we are adding classes dynamically to second dropdown list.
Create one more CSS file and define "Dropdown-submenu" class.
Apply this "Dropdown-submenu" class to your inner "LI" tag as:
<ul class="nav navbar-nav">
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li class="dropdown dropdown-submenu">
Dropdown2 <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li ><a href="#" >Something</a>
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li>Separated link
</li>
</ul>
</li>
The CSS file Will define Dropdown-submenu as:
.dropdown-submenu {
position:relative; } .dropdown-submenu>.dropdown-menu {
top:0;
left:100%;
margin-top:-6px;
margin-left:-1px;
-webkit-border-radius:0 6px 6px 6px;
-moz-border-radius:0 6px 6px 6px;
border-radius:0 6px 6px 6px; } .dropdown-submenu:hover>.dropdown-menu {
display:block; } .dropdown-submenu>a:after {
display:block;
content:" ";
float:right;
width:0;
height:0;
border-color:transparent;
border-style:solid;
border-width:5px 0 5px 5px;
border-left-color:#333333;
margin-top:5px;
margin-right:-10px; } .dropdown-submenu:hover>a:after {
border-left-color: #999999; } .dropdown-submenu.pull-left {
float:none; } .dropdown-submenu.pull-left>.dropdown-menu {
left:-100%;
margin-left:10px;
-webkit-border-radius:6px 0 6px 6px;
-moz-border-radius:6px 0 6px 6px;
border-radius:6px 0 6px 6px; }

dropdown menu, Brootstrap, menu center, text left-sided

I am sure somebody has aleady posted such a question but I could not find a solution.
I am using Ruby on Rails, Brootstrap and I want to be my dropdown menu(whole) in the middle of the page, but the text (links like We, What we do and etc...) in the dropdown-menu should be left-sided.
How can I do it?
<div class="btn-toolbar">
<div class="btn-group">
<button id="action-btn" class="btn dropdown-toggle" data-toggle="dropdown">
About us
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="del">
<strong> We</strong>
</a>
</li>
<li>
<div class="mcol">
<ul class ="sub">
<div class ="subcolumns menuactivity">
What we do
</li>
Countries
</div>
</ul>
<li>
<a href="del">
<strong>References </strong>
</a>
</li>
</ul>
<div class="btn-group">
<button id="action-btn" class="btn dropdown-toggle" data-toggle="dropdown">
News & Events
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="del">
<strong>Calender</strong>
</a>
</li>
<ul class ="sub">
<div class ="subcolumns menuactivity">
<li>
News archive
</li>
</ul>
</div>
</ul>
</div>
If you're using bootstrap as it is by default you can try below
<a class="pull-left" href="details"> What we do </a>
I have updated with an example.
http://jsfiddle.net/acc8t/
I did this by using below css
.sub{margin-left:0px;}
I have founf as well another solution already.
Just to put in css the following code:
.dropdown-menu {
text-align: left;
}
.btn-toolbar{
text-align: center;
padding-bottom:40px;
}​

Resources