title: create Horizontal sub menu with css
body: <p>I want to create a horizontal sub menu when hover on main menu like this</p>
  
  <p>But this is what I have made</p>
  
  <p>How do I resolve this problem?</p>
  
  <p><a href="http://i.stack.imgur.com/ruGTr.png" rel="nofollow">create this</a></p>
  
  <p>but i want this <a href="http://i.stack.imgur.com/fTz8d.png" rel="nofollow">enter image description here</a></p>
  
  <p>/**********************************************************************/</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
      margin: 0;
      padding: 0;
  }
  
  #iri-header {
      font-family: 'Iranian Sans';
      font-size: 15px;
      line-height: 1.142;
      display: block;
      border: 0;
      width: 1349px;
      height: 40.5px;
      border-bottom: 1px solid gray;
  }
  
  #orb-header {
      position: relative;
  }
  
  .iri-header-container {
      width: 1008px;
      height: 39.5px;
      margin: 0 auto;
      border: 0;
      padding: 0 16px;
  }
  
  .logo {
      width: 96px;
      height: 39.5px;
      border-left: 1px solid black;
      float: right;
  }
  
      .logo img {
          float: right;
          padding-top: 8px;
      }
  
  .loging {
      width: 197.5px;
      height: 39.5px;
      float: right;
      cursor: pointer;
      border-left: 1px solid black;
  }
  
      .loging:hover {
          border-bottom: 2px solid black;
      }
  
  #vorod {
      float: right;
      padding: 12px;
  }
  
  .loging img {
      width: 30px;
      height: 30px;
      margin-top: 6px;
      margin-left: 8px;
  }
  
  .search {
      width: 300px;
      height: 39.5px;
      border-right: 1px solid black;
  }
  
  .Search {
      width: 45px;
      height: 39.5px;
      float: right;
      margin-right: 10px;
  }
  
      .Search img {
          width: 100%;
          height: 100%;
      }
  
  .brand {
      width: 1349px;
      height: 95px;
      background-color: #BB1919;
      display: block;
      border: 0;
      position: relative;
  }
  
  .site-brand {
      width: 976px;
      height: 59px;
      margin: 0 auto;
  }
  
  .brand .site-brand a &gt; span {
      float: right;
      font-family: A Ketab;
      font-size: 35px;
      margin-top: 6px;
      color: #ffffff;
      text-decoration: none;
  }
  
  .menu {
      width: 1349px;
      height: 36px;
  }
  
  .menu-container {
      width: 1349px;
      height: 35px;
      background-color: #A91717;
  }
  
  .menu-ul {
      margin: 0 auto;
      height: 35px;
  }
  
  #main_menu {
      list-style: none;
      float: right;
      margin-right: 93px;
      font-size: 16px;
  }
  
      #main_menu li {
          display: inline-block;
          vertical-align: bottom;
      }
  
          #main_menu li a {
              display: block;
              padding: 10px; /* For example */
              position: relative;
          }
  
  li a {
      display: inline-block; /* To enable padding */
      padding: 10px; /* For example */
  }
  
  li:not(:hover) .submenu {
      display: none;
  }
  
  li:hover .submenu {
      position: absolute;
      right: 0; /* If you want to stick it to the left edge, remove this line. */
      white-space: nowrap;
  }
  
  #main_menu li:hover {
      background-color: #eb4b4b;
  }
  
  #main_menu li ul {
      list-style: none;
      background-color: #820e0e;
      position: absolute;
      width: 100%;
      float: right;
      display: none;
      direction: rtl;
      margin-right: 60px;
  }
  
  #main_menu li:hover ul {
      display: block;
  }
  
  #main_menu li ul li {
      float: left;
      direction: rtl;
      border-bottom: 1px solid #BB4545;
      display: block;
  }
  
      #main_menu li ul li a {
          float: none;
          display: block;
      }
  
  li {
      display: inline-block;
      position: relative;
      vertical-align: bottom;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;سایت IRI&lt;/title&gt;
      &lt;link href="~/Content/StyleSheet.css" rel="stylesheet" /&gt;
      &lt;script src="~/Scripts/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;link href="~/Content/bootstrap.min.css" rel="stylesheet" /&gt;
      &lt;link href="~/Content/bootstrap-rtl.min.css" rel="stylesheet" /&gt;
      &lt;link href="~/Content/bootstrap-theme-rtl.min.css" rel="stylesheet" /&gt;
      &lt;script src="~/Scripts/jquery-3.1.0.min.js"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/jquery.unobtrusive-ajax.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
    &lt;div&gt;
        &lt;header id="iri-header"&gt;
          &lt;div id="orb-header"&gt;
            &lt;div class="iri-header-container"&gt;
              &lt;div class="logo"&gt;
                &lt;a href="#"&gt;
                  &lt;img src="~/Content/img/Logo.png" /&gt;
                &lt;/a&gt;
              &lt;/div&gt;
              &lt;div class="loging"&gt;
                &lt;a href="/Home/Register"&gt;
                  &lt;div class="loging-container"&gt;
  
                    &lt;span id="vorod"&gt;ورود/ثبت نام&lt;/span&gt;
  
                    &lt;img src="~/Content/img/pic1.png" /&gt;
                  &lt;/div&gt;
                &lt;/a&gt;
              &lt;/div&gt;
              &lt;div class="search"&gt;
                @Html.Partial("P_Search")
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/header&gt;
        &lt;div class="brand"&gt;
          &lt;div class="site-brand"&gt;
            &lt;a href="/Home/Index"&gt;
              &lt;span&gt;اخبار ایران و جهان&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
          &lt;div class="menu"&gt;
            &lt;div class="menu-container"&gt;
              &lt;div class="menu-ul"&gt;
                &lt;ul id="main_menu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;1صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی2&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;3صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;4صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;
                    &lt;a href="#"&gt;صفحه اصلی5&lt;/a&gt;
                    &lt;ul class="sub-menu"&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
                  &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی6&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;7صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;
                    &lt;a href="#"&gt;8صفحه اصلی&lt;/a&gt;
                    &lt;ul class="sub-menu"&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
                  &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی9&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;10صفحه اصلی&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;صفحه اصلی11&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>